Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1970267ybl; Sat, 31 Aug 2019 05:42:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtwtIl0vh4oF1YXZ1rzvELD3HKGYBpcyV8doHp86ZVRtv0NNd7d2DNFUISKik69QYND4jp X-Received: by 2002:a63:10a:: with SMTP id 10mr17366315pgb.281.1567255366778; Sat, 31 Aug 2019 05:42:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567255366; cv=none; d=google.com; s=arc-20160816; b=ch1Arb2eT1O7+3MZ4ZoIWoZE/hvRevPtjQlI/ImPeV++HtMmseY5l1mwHsQ5RIAJ8E 8yd23ujIhwDfyqyp7yKvQ+VhWQLPDM6aCBYWnRbeu37hl0hUUhHIRVCP4Yy+YC2Y3/SZ 9sS+FQNS+kB6bBt+xklQC9WLLA8j6SYWVq94l3JPXzTw9kSorUag2zc1wkl62swzcSSM rVYzP+pfmfGj2RpidInim+M62hhfy+GZeJnSOPsOMt+vCuIpPFC95dNKjJgs1XcxPAQ1 drjN9n6ASNOB8mSKCs/2XxWwT2HL3FjiBLcbOs5ArGDh0P0uMNstY1XQKTny7+RvNGtE XBEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=waqEPDkB4Blyhmd/zWpwb02Qvy3ECNdh10x4peOYnHg=; b=oVbixeveS3xSCnauGMLwDAFB03YYoQVArLZ1NPTWGp2keMR3QyQ6w+5tau/MUu/Pmi FyKEYBExSKPio87aTabLRdrHpUzqRGYWLTCFmYK+N0yAuVbe9qnqLvjNpuhjSZ4UWZA6 6eC2xusxFgx1NmCyEoNXj+QDxFmHMXRsHisNq8/6SXat+aui8ctfPDhrIFotF4Od1+se DsA+BIuQu8gj8rAbYq00GfTH5+NcDBK0+nJpH0MfePFpZbZ+dD3DT07erhjZ7zTixxDB +0Yp5uHaTYk5hsDcQiMZX5BSuH770EiK/q1Gnq4pi8eTfWv2VPH+8zZU6CogDS9BNyiL cxzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si7096966plw.253.2019.08.31.05.42.27; Sat, 31 Aug 2019 05:42:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728052AbfHaMlW (ORCPT + 99 others); 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 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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: