]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
scsi: ufs: Use kmemdup in ufshcd_read_string_desc()
authorYueHaibing <yuehaibing@huawei.com>
Sat, 31 Aug 2019 12:44:24 +0000 (12:44 +0000)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sat, 7 Sep 2019 20:39:30 +0000 (16:39 -0400)
Use kmemdup rather than duplicating its implementation

Link: https://lore.kernel.org/r/20190831124424.18642-1-yuehaibing@huawei.com
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufshcd.c

index 5c2eb4866044cabd1c6ed1484af0063ba8acb1d8..c4a015e42045dbe3dd33a61aaf752749974099b9 100644 (file)
@@ -3309,12 +3309,11 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
                str[ret++] = '\0';
 
        } else {
-               str = kzalloc(uc_str->len, GFP_KERNEL);
+               str = kmemdup(uc_str, uc_str->len, GFP_KERNEL);
                if (!str) {
                        ret = -ENOMEM;
                        goto out;
                }
-               memcpy(str, uc_str, uc_str->len);
                ret = uc_str->len;
        }
 out: