Message ID | 20240821012403.1947764-1-lizetao1@huawei.com |
---|---|
State | Accepted |
Commit | 4fa6e533d1d47d74ea3976d043c648d167a2bc4f |
Headers | show |
Series | [-next] Bluetooth: btrtl: Use kvmemdup to simplify the code | expand |
diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index f2f37143c454..96754c8a4461 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -878,10 +878,8 @@ static int rtl_load_file(struct hci_dev *hdev, const char *name, u8 **buff) if (ret < 0) return ret; ret = fw->size; - *buff = kvmalloc(fw->size, GFP_KERNEL); - if (*buff) - memcpy(*buff, fw->data, ret); - else + *buff = kvmemdup(fw->data, fw->size, GFP_KERNEL); + if (!*buff) ret = -ENOMEM; release_firmware(fw);
Use kvmemdup instead of kvmalloc() + memcpy() to simplify the code. No functional change intended. Signed-off-by: Li Zetao <lizetao1@huawei.com> --- drivers/bluetooth/btrtl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)