]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Bluetooth: btrtl: Use kvmemdup to simplify the code
authorLi Zetao <lizetao1@huawei.com>
Wed, 21 Aug 2024 01:24:03 +0000 (09:24 +0800)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 10 Sep 2024 17:05:57 +0000 (13:05 -0400)
Use kvmemdup instead of kvmalloc() + memcpy() to simplify the code.

No functional change intended.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
drivers/bluetooth/btrtl.c

index d95a1cfa35ed0c9a544787891d70252fb5bf03f9..4c0f551a9975e1b8059e740995324df77e3b8a58 100644 (file)
@@ -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);