From: Li Zetao Date: Wed, 21 Aug 2024 01:24:03 +0000 (+0800) Subject: Bluetooth: btrtl: Use kvmemdup to simplify the code X-Git-Tag: v6.12-rc1~232^2~19^2~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=52bc7d66659faac6e5a47e3ab38d8c8f590e94e5;p=thirdparty%2Fkernel%2Flinux.git 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 --- 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);