From patchwork Sat Aug 31 12:44:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yue Haibing X-Patchwork-Id: 11124903 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4D40112C for ; Sat, 31 Aug 2019 12:41:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B357F23407 for ; Sat, 31 Aug 2019 12:41:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727816AbfHaMlW (ORCPT ); Sat, 31 Aug 2019 08:41:22 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6159 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727342AbfHaMlW (ORCPT ); Sat, 31 Aug 2019 08:41:22 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id AC1C3B2A14BFC027C584; Sat, 31 Aug 2019 20:41:12 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Sat, 31 Aug 2019 20:41:06 +0800 From: YueHaibing To: Alim Akhtar , Avri Altman , Pedro Sousa , "James E.J. Bottomley" , "Martin K. Petersen" , Tomas Winkler , Subhash Jadavani CC: YueHaibing , , , Subject: [PATCH -next] scsi: ufs: Use kmemdup in ufshcd_read_string_desc() Date: Sat, 31 Aug 2019 12:44:24 +0000 Message-ID: <20190831124424.18642-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use kmemdup rather than duplicating its implementation Signed-off-by: YueHaibing --- drivers/scsi/ufs/ufshcd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index acf298da054c..6d5e2f5d8468 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -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: