Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10514069imu; Thu, 6 Dec 2018 02:23:08 -0800 (PST) X-Google-Smtp-Source: AFSGD/UzilCk/6j5ADyxuGvJ6AU3cBPBoFZqOLWN79VbVnkPMy4C8aEQf79D49/K0O/uUSl+l2Hd X-Received: by 2002:a63:b30f:: with SMTP id i15mr23690891pgf.240.1544091788669; Thu, 06 Dec 2018 02:23:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544091788; cv=none; d=google.com; s=arc-20160816; b=oeJIhyFUgWcnljl/ZhhxveCwXwKORsLFBRViRtg3WDhvnaYhpewv9TUUZcZGJeH6+P Xap02IPaCcSwddrp9WoU1yHrf38qOsD64z/lZ1nMRJE2vgiy3PKsYIPKruK/p1qyFfbJ oCbOZuIiTzhwoFNz3S877vYTZoHrw8on6csVEHvjmGeeezi7WBnJQ/JB3hW6ZYdfB7Ta 7sPssl5pyeTxpGXtyMdLeq2kzLARPs2FrZ+YB7cF/0qY57jphyv7w1t1DBB9bXIpknbg QvIkq4iqChKVBDn/IkQb20RLlsTuv+IIgM0kUn53xpgDfAPJnGa8G4Ul3sSRW1Zm33Gh 5hKA== 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=dNZQiZpDbkesGxm2kIjG9QASCBCm2GdwF69XSzfwZPs=; b=bum77OpvaZ6Y+By02hwtUIc8U8YFTMTboc44FniLJ3b1fZEoMcVJrb8p84lgRTPPoX m+Bwk7kmIPuv4u564mEsi1KatWsSCJqmqDbM7JergXconCYV488l5n4HbzVAlG4ta35m e7Gv9Ywe0nBUVFL8nT9OUBfoyZxpxWfUqY1DXCL37wXJLZVT+GujF1BPWHnS35mk0f/F VTlcLq1c4pDA9aTw0G1fwcHHxrGDjb9gVBi8emM4gUyqwgC97J8AO/oS9vYgAhCsN4BQ 0g/+Rn/fF1SN3+IZmujHxNPilAupsk+nidTiESFIWz83/lMio4+KsOcxq+r5AmoMHuLu WQ3Q== 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 bh5si4849409plb.42.2018.12.06.02.22.52; Thu, 06 Dec 2018 02:23:08 -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 S1729054AbeLFKWJ (ORCPT + 99 others); Thu, 6 Dec 2018 05:22:09 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:18494 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727575AbeLFKWI (ORCPT ); Thu, 6 Dec 2018 05:22:08 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id CFB0426C40D3C1A4E504; Thu, 6 Dec 2018 18:22:04 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id wB6ALroO018536; Thu, 6 Dec 2018 18:21:53 +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 2018120618222453-15119061 ; Thu, 6 Dec 2018 18:22:24 +0800 From: Wen Yang To: Kishon Vijay Abraham I , Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, Wen Yang , Bob Copeland , Gustavo Pimentel , Niklas Cassel , Greg Kroah-Hartman , Cyrille Pitchen Subject: [PATCH] PCI: endpoint: functions: Use kmemdup instead of duplicating its function Date: Thu, 6 Dec 2018 18:21:05 +0800 Message-Id: <20181206102105.53098-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 18:22:24, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-12-06 18:21:41 Content-Transfer-Encoding: quoted-printable X-MAIL: mse01.zte.com.cn wB6ALroO018536 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: Bob Copeland CC: Kishon Vijay Abraham I CC: Lorenzo Pieralisi CC: Bjorn Helgaas CC: Gustavo Pimentel CC: Niklas Cassel CC: Greg Kroah-Hartman CC: Cyrille Pitchen CC: linux-pci@vger.kernel.org (open list:PCI ENDPOINT SUBSYSTEM) CC: linux-kernel@vger.kernel.org (open list) --- drivers/pci/endpoint/functions/pci-epf-test.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/en= dpoint/functions/pci-epf-test.c index 3e86fa3c7da3..6e42daa2a651 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -169,14 +169,12 @@ static int pci=5Fepf=5Ftest=5Fread(struct pci=5Fepf= =5Ftest *epf=5Ftest) goto err=5Faddr; } =20 - buf =3D kzalloc(reg->size, GFP=5FKERNEL); + buf =3D kzalloc(src=5Faddr, reg->size, GFP=5FKERNEL); if (!buf) { ret =3D -ENOMEM; goto err=5Fmap=5Faddr; } =20 - memcpy(buf, src=5Faddr, reg->size); - crc32 =3D crc32=5Fle(~0, buf, reg->size); if (crc32 !=3D reg->checksum) ret =3D -EIO; --=20 2.19.1