Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2645848pxj; Sun, 23 May 2021 06:36:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwzj1WsTD9COvXRFnNJt/U7+7cqgkFoHn0w41XP/cyH7YVbXDwCLbAtA9gtVz1bdQ7uBFO X-Received: by 2002:a05:6602:2f0f:: with SMTP id q15mr10716887iow.75.1621777004853; Sun, 23 May 2021 06:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621777004; cv=none; d=google.com; s=arc-20160816; b=z0ulsytmBT+1DPdtRJM2Z/sZKqoLaBWgSP1LmkC/wbHWy42n/6d/Ui+cjofXAro/UL C2Q+eHrcI7mQVOQHqbsHArSERE9gEtz8hbM4FRpyA70CwFkQTfA/U3dvhaOW+bNwFU5e gFPOkgLg8zq/7V9IoTpBpsVvPnSxGQ2c1srHMJSNH5SWSFATBmxWXm/ewkhe5n7oJ/Aq jY8W8WddKgNT0kKDDzHamTEM62ibleliTaoVcmZV9nrUHx9c/eMjGr6zwVrGjPZfYgc7 EqhXvqr3xb8MCDs2cAUUWcd+aDSsVw98TEG8K7vozgtR2Dj4qUze/za2QjW1Fs44rmSB jfnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-disposition :mime-version:user-agent:in-reply-to:subject:cc:to:from:message-id :date; bh=A2UTwmJMXEbnMMKjKoR/3RgNX+2qrckYKvHqscjG9mc=; b=Fp+jqtW4sLEThvkPdSp1ux/8heyvydD+OgpCPeoCFv1qPTdS840jHZIt12VpDlCMqw g56NlqWr45lHdFeN/Se/otsjgeE68xwkoSJ4ZM/3QZKsK2Cz7CdAMLk1nfWpJyNudavi Q6Y2TvY6aE99HmUCtUP7IfJJydb+pgkIxBeGXPo4utUXkjBjKDQKCt5NsCjzanEYtwYy BNdh8x5IPG4yhabFBQY27BwrhE4xj9lPeya+5psytqisHUbLTaBC92zJvzW60kQkdrzb ugmzLkzcXe8HLM+SpyPnBx0/Zv/qZY/5NXAgUo9YsCdvvUcJnbnsE/6D8wU8VPq/5DaC QIKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si590099ioj.93.2021.05.23.06.36.02; Sun, 23 May 2021 06:36:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbhEWN0n convert rfc822-to-8bit (ORCPT + 99 others); Sun, 23 May 2021 09:26:43 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:22861 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231757AbhEWN0m (ORCPT ); Sun, 23 May 2021 09:26:42 -0400 Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4Fp1L224XdzB6pT; Sun, 23 May 2021 15:25:14 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dsG_czGrW-V2; Sun, 23 May 2021 15:25:14 +0200 (CEST) Received: from vm-hermes.si.c-s.fr (vm-hermes.si.c-s.fr [192.168.25.253]) by pegase1.c-s.fr (Postfix) with ESMTP id 4Fp1L212RgzB6hw; Sun, 23 May 2021 15:25:14 +0200 (CEST) Received: by vm-hermes.si.c-s.fr (Postfix, from userid 33) id C951716D; Sun, 23 May 2021 15:29:37 +0200 (CEST) Received: from 37-164-13-85.coucou-networks.fr (37-164-13-85.coucou-networks.fr [37.164.13.85]) by messagerie.c-s.fr (Horde Framework) with HTTP; Sun, 23 May 2021 15:29:37 +0200 Date: Sun, 23 May 2021 15:29:37 +0200 Message-ID: <20210523152937.Horde.5kC0kzvaP3No5BC63LlZ_A7@messagerie.c-s.fr> From: Christophe Leroy To: YueHaibing Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, rasmus.villemoes@prevas.dk, kuba@kernel.org, davem@davemloft.net, leoyang.li@nxp.com Subject: Re: [PATCH net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy In-Reply-To: <20210523075616.14792-1-yuehaibing@huawei.com> User-Agent: Internet Messaging Program (IMP) H5 (6.2.3) Content-Type: text/plain; charset=UTF-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org YueHaibing a écrit : > Issue identified with Coccinelle. > > Signed-off-by: YueHaibing > --- > drivers/net/ethernet/freescale/ucc_geth.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/freescale/ucc_geth.c > b/drivers/net/ethernet/freescale/ucc_geth.c > index e0936510fa34..51206272cc25 100644 > --- a/drivers/net/ethernet/freescale/ucc_geth.c > +++ b/drivers/net/ethernet/freescale/ucc_geth.c > @@ -3590,10 +3590,10 @@ static int ucc_geth_probe(struct > platform_device* ofdev) > if ((ucc_num < 0) || (ucc_num > 7)) > return -ENODEV; > > - ug_info = kmalloc(sizeof(*ug_info), GFP_KERNEL); > + ug_info = kmemdup(&ugeth_primary_info, sizeof(*ug_info), > + GFP_KERNEL); Can you keep that as a single line ? The tolerance is 100 chars per line now. > if (ug_info == NULL) > return -ENOMEM; > - memcpy(ug_info, &ugeth_primary_info, sizeof(*ug_info)); > > ug_info->uf_info.ucc_num = ucc_num; > > -- > 2.17.1