Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10640946imu; Thu, 6 Dec 2018 04:34:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/VCMnfHmpao0bYc+MKFO/pYk5DyczbbwcDQlknZMBgipDz6sT5B4MUIIZ8pnGL+4ohQoLYU X-Received: by 2002:a62:31c1:: with SMTP id x184mr29168068pfx.204.1544099657256; Thu, 06 Dec 2018 04:34:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544099657; cv=none; d=google.com; s=arc-20160816; b=psaq2NehAeZ7abb9A5AQ2piTqGa0LBCpuz7xXwlFr0rGMKjul9mRaDa+hwgp41YGCM NUphtjw4NIFDCNbM7cU9rCoqZH9oPflmrqZX4R/EEgh7WTgJnP/GaC7ocdSun2XB9+5D nABJ5WPXRRJd3XdMC7jo5ffzTwff+F0PlJN8c/bZUHqe7blYeqiVXwaFwOsMepQWQsfj 7bCwiOb7jNYFiUw3EX05bBPD6YCVJs1jwxjFuet/RbUoc7E11o3qwe2FoN+GhG3UwO6l TKJsEX58RNZLDuVIDvEO2d1Ic6BvwiewkhZwX95XrlL7f2/X3GyS3yNT9ugUWwbbzz71 KdNA== 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=oR6Wb/X3E3LSHrLRl11tZCUpznwe87Cs37AFhjIIoEU=; b=ZcuQU/jAGiGFWTcRCFME4XnZ0jJz/RgLKY3K7I7qObd5/RH9oIz6neeH/Q3tiIqnTH BtpoilP5ZbXypPfZ3GRQPX8GRAxSmJEYayJQKAUDJrU+B7dmjQrzFIktVNvmdveeJ+2q IPIjbENf9mJ40AASKSrg35ai5KlIH3PTyPBt6naoMuTQCMLb5UNtMAPm2507O7sVBz9e yYNYkqyt2WHVlSJBWkaMT6+f9ZXPwQv4VJafsIpDPAZ7KRB9TVv0YbkC19cuK95v6TdA JKxHWw69oGtNCCw4sdBWxCvnKzAxeSVHlqpCJI1CpKAO2QjLWYchA9L2gcUWxZVMAyUK PQUQ== 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 189si173552pgh.320.2018.12.06.04.33.58; Thu, 06 Dec 2018 04:34:17 -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 S1729468AbeLFMbi (ORCPT + 99 others); Thu, 6 Dec 2018 07:31:38 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:55164 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728764AbeLFMbi (ORCPT ); Thu, 6 Dec 2018 07:31:38 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 519B5EE1C76C85211367; Thu, 6 Dec 2018 20:29:38 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id wB6CTY2M056602; Thu, 6 Dec 2018 20:29:34 +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 2018120620300448-15142737 ; Thu, 6 Dec 2018 20:30:04 +0800 From: Wen Yang To: Mauro Carvalho Chehab , Tomoki Sekiyama Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, Wen Yang Subject: [PATCH] media: siano: Use kmemdup instead of duplicating its function Date: Thu, 6 Dec 2018 20:29:10 +0800 Message-Id: <20181206122910.50908-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:30:04, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-12-06 20:29:22 Content-Transfer-Encoding: quoted-printable X-MAIL: mse01.zte.com.cn wB6CTY2M056602 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: Mauro Carvalho Chehab CC: Tomoki Sekiyama CC: linux-media@vger.kernel.org CC: linux-kernel@vger.kernel.org --- drivers/media/usb/siano/smsusb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/sms= usb.c index be3634407f1f..2ffded08407b 100644 --- a/drivers/media/usb/siano/smsusb.c +++ b/drivers/media/usb/siano/smsusb.c @@ -225,10 +225,9 @@ static int smsusb=5Fsendrequest(void *context, void *b= uffer, size=5Ft size) return -ENOENT; } =20 - phdr =3D kmalloc(size, GFP=5FKERNEL); + phdr =3D kmemdup(buffer, size, GFP=5FKERNEL); if (!phdr) return -ENOMEM; - memcpy(phdr, buffer, size); =20 pr=5Fdebug("sending %s(%d) size: %d\n", smscore=5Ftranslate=5Fmsg(phdr->msg=5Ftype), phdr->msg=5Ftype, --=20 2.19.1