From 52bc7d66659faac6e5a47e3ab38d8c8f590e94e5 Mon Sep 17 00:00:00 2001 From: Li Zetao Date: Wed, 21 Aug 2024 09:24:03 +0800 Subject: [PATCH] Bluetooth: btrtl: Use kvmemdup to simplify the code Use kvmemdup instead of kvmalloc() + memcpy() to simplify the code. No functional change intended. Signed-off-by: Li Zetao Signed-off-by: Luiz Augusto von Dentz --- drivers/bluetooth/btrtl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index d95a1cfa35ed0..4c0f551a9975e 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -890,10 +890,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); -- 2.39.5