From patchwork Thu Dec 6 10:21:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Yang X-Patchwork-Id: 10715571 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 495F113BB for ; Thu, 6 Dec 2018 10:22:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 383992E26E for ; Thu, 6 Dec 2018 10:22:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C02C2E28B; Thu, 6 Dec 2018 10:22:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8F1E2E284 for ; Thu, 6 Dec 2018 10:22:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727806AbeLFKWI (ORCPT ); Thu, 6 Dec 2018 05:22:08 -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 X-MAIL: mse01.zte.com.cn wB6ALroO018536 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/endpoint/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_epf_test_read(struct pci_epf_test *epf_test) goto err_addr; } - buf = kzalloc(reg->size, GFP_KERNEL); + buf = kzalloc(src_addr, reg->size, GFP_KERNEL); if (!buf) { ret = -ENOMEM; goto err_map_addr; } - memcpy(buf, src_addr, reg->size); - crc32 = crc32_le(~0, buf, reg->size); if (crc32 != reg->checksum) ret = -EIO;