Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10645757imu; Thu, 6 Dec 2018 04:39:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/UsgZQ1qGwbqhfa4qpUXGgzDAU0RCmlEZfSTCoeEYuRzMESysA6YB/S4fXSPmqhRErciPAg X-Received: by 2002:a17:902:f64:: with SMTP id 91mr14443619ply.132.1544099961144; Thu, 06 Dec 2018 04:39:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544099961; cv=none; d=google.com; s=arc-20160816; b=xs0/A+ptiCsu/mlJ7BM4LRKKi+Ib1oFXjNA/37uqD04SVQhjlU7LXT2mpXk+vkt6a6 mr7mhtV3lNA9+2+h3cdZFxC40bQ9M09llUjkMAo3WFwGrXZ1O0GXNQT85+qMx9P5qITi 0vEoLy2vOTMi5ENFTLGi5yn6JgdF0Md1anAmf5WW/rGQ8677SNgpcfy+2QmvK2qwWEOP YfCR9gAesW9FYjrQq8l04yTVz62EULtG0CpaskgUWpzJfIcFey8CeE0sHmWlac0asIEe U7gMdYeZNB73pTdzOSpWFOB9RNPSwMxEyHQ58Y0VbK9gwMYpxhzuCHfk313qc5oyx9Hm wCyg== 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=4lfpYIgVRpQtRyPEJOznkk+Tb80mTxGtRgbPpSA9bWs=; b=JqAVYb9ys98OTZ0+BmE+19HzLokHuSOJ2whGfRSC59jiMKlR+kWLqYgpxFlz2dcWSH QGu8A4jY9ZDfmYuiD/Kb0eOcxaRJZD1dMYxP6XdGyHNasxMr9lXPH3UAb7lOligshSew HsLS03odyMU+m3/XZiAmBalOI6v9W7hv8cExJPBkehQpqtKKAu/Ijmb7oOoXoQgd4qpw r6sUfna1JXaoRxpCo6Dhp3JJRRiFDJajqtqJkaJMyhRFKPRqfN+KMp1XkRSYpRCHUT3r laAeJ39VuOVZ7ICph97wzqx5yc2tfX1erMfdNTzTJogYi/aL4BmlFsd9RLe/ID9VDGp/ e2FA== 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 61si181903plc.364.2018.12.06.04.39.04; Thu, 06 Dec 2018 04:39:21 -0800 (PST) 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 S1729587AbeLFMhz (ORCPT + 99 others); Thu, 6 Dec 2018 07:37:55 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:46190 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728144AbeLFMhz (ORCPT ); Thu, 6 Dec 2018 07:37:55 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 10C8A4DE0564BC2ED0BA; Thu, 6 Dec 2018 20:37:53 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id wB6CbeWD063195; Thu, 6 Dec 2018 20:37:41 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from LIN-A6CB96A0603.zte.intra ([10.90.106.118]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018120620381314-15145753 ; Thu, 6 Dec 2018 20:38:13 +0800 From: Wen Yang To: Sathya Prakash , Chaitra P B , Suganath Prabu Subramani Cc: MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, Wen Yang Subject: [PATCH] scsi: message: fusion: Use kmemdup instead of duplicating its function Date: Thu, 6 Dec 2018 20:37:33 +0800 Message-Id: <20181206123733.59427-1-wen.yang99@zte.com.cn> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-12-06 20:38:13, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-12-06 20:37:29 Content-Transfer-Encoding: quoted-printable X-MAIL: mse01.zte.com.cn wB6CbeWD063195 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kmemdup has implemented the function that kmalloc() + memcpy(). We prefer to kmemdup rather than code opened implementation. This issue was detected with the help of coccinelle. Signed-off-by: Wen Yang CC: Sathya Prakash CC: Chaitra P B CC: Suganath Prabu Subramani CC: MPT-FusionLinux.pdl@broadcom.com CC: linux-scsi@vger.kernel.org CC: linux-kernel@vger.kernel.org --- drivers/message/fusion/mptbase.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptb= ase.c index ba551d8dfba4..f8ec116cb9a4 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -6001,13 +6001,12 @@ mpt=5FfindImVolumes(MPT=5FADAPTER *ioc) if (mpt=5Fconfig(ioc, &cfg) !=3D 0) goto out; =20 - mem =3D kmalloc(iocpage2sz, GFP=5FKERNEL); + mem =3D kmemdup((u8 *)pIoc2, iocpage2sz, GFP=5FKERNEL); if (!mem) { rc =3D -ENOMEM; goto out; } =20 - memcpy(mem, (u8 *)pIoc2, iocpage2sz); ioc->raid=5Fdata.pIocPg2 =3D (IOCPage2=5Ft *) mem; =20 mpt=5Fread=5Fioc=5Fpg=5F3(ioc); --=20 2.19.1