Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2469910pxj; Sun, 23 May 2021 01:04:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhPtmStLzSPXJ45dilttA//xvIbp68A+Y218+Sk5m/CLeKkBYe5u3zpdNw17ocZ8/q38dm X-Received: by 2002:a05:6e02:b:: with SMTP id h11mr9184935ilr.18.1621757049906; Sun, 23 May 2021 01:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621757049; cv=none; d=google.com; s=arc-20160816; b=D89eLtJj+NCaMMp5dh2l0B2cka6W/hWIoyuyqwd7eIXCl1bE0Puiw4zMyrM/PRPkWG uOkO5IYlxHcX/W87T1+QocACgxucRNlmnX9f6/Fc2t87+0g1zwpb4BnlZJJ+ZWaO33MX biB1XkWtPaUVRbTaWvxDkHc5ih+X85m0FHVHc+laWM6/vd4NnC8RbHx9CA0QfJJ81+2M XBITDWM6B/Ku/VT2vpfqrefX0uSuMSHmmHLZGEqbZilEkaaJq3zoPVtxxQvG4eEx4RXW SqbGH+WX8j4JsYqdOKstrsMfUbIBfdfArlMWUu6072/wJZPzrKTq9AuY4/EmwrxnGTuM maVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=QO9gXHfxDt6bjZIh4Di02OqY5UQFTzrSOXx+8z4hpeQ=; b=PWFgfLU3iiIakKPVth88rtPjGgviFPUVd20RcNO17E2g/YEW0Wjqe5NJ5cJykYS+E2 s4RvLzsSXrxugzYavX7wvrTs+XZ5DeQjbYwlLD6ebqBghrznl40OTRqlYGjScWgnQQKJ KCGOj+j6Pr0dShyl1q+w8pnvss3iZ57sCbqLIOKfMR+Rfhn3T+Ub8MCnxIuz0wzpx1uj wgeYtlGXx4DDDl+w1Fmrx0ZTnUh967WviGVZTguYMoa6L9BzEHoJCOPdfgCPUgBAuRCn cwScTGUu0YpX+PYDuvAwGGfiUiADwp35gtWHb7NeGiw3N0tc6RGbh3qyJFVuVWEneVSr hldg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si2533204ilt.65.2021.05.23.01.03.54; Sun, 23 May 2021 01:04:09 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231682AbhEWICW (ORCPT + 99 others); Sun, 23 May 2021 04:02:22 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:3915 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231654AbhEWICS (ORCPT ); Sun, 23 May 2021 04:02:18 -0400 Received: from dggems701-chm.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Fnt48321tzCvy3; Sun, 23 May 2021 15:57:44 +0800 (CST) Received: from dggema769-chm.china.huawei.com (10.1.198.211) by dggems701-chm.china.huawei.com (10.3.19.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Sun, 23 May 2021 16:00:34 +0800 Received: from localhost (10.174.179.215) by dggema769-chm.china.huawei.com (10.1.198.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Sun, 23 May 2021 16:00:33 +0800 From: YueHaibing To: , , , CC: , , , YueHaibing Subject: [PATCH net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy Date: Sun, 23 May 2021 15:56:16 +0800 Message-ID: <20210523075616.14792-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggema769-chm.china.huawei.com (10.1.198.211) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); 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