Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp546784pxk; Wed, 9 Sep 2020 12:03:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMtWJywyK8BxKOzk9fdoc3e1vvd0Ksb6jR5Sz3xrk36Azt1d9mlxiIi5JXu5XitGvBgu2G X-Received: by 2002:aa7:d648:: with SMTP id v8mr4191754edr.159.1599678211682; Wed, 09 Sep 2020 12:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599678211; cv=none; d=google.com; s=arc-20160816; b=ko1lU/niMCynr3oYcP/fO22sE9PYFYjjnSlUgYX1jreIa5F1SaW3KVloR4RV437F3K 0XDaGqxllUgTfkP5s4h0XuuRKc3C5jgFtVtRKX5GgPgVcob2qOUDAVd6nu/SmxpqhgHl vfvICDJ6+S51KSRrE2CqAgjiwXkjq32eLAwijrkAURD7f8OhrvIOS05dyZ3oq+up8izE etNkgYQGPPKgL49QK6rJ8xUriXcGsx1CwJxs/+ecGcl5mBasW0RtAlJblaDop9mDPmgH imnRqgrQBiUEkVlaYt62CDk4qAIT5hFMhZZUj5fCLe+HydBVv8JYa+Ph5P5dMxyyTEab UhXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=uXnjw/VPfhPNUnKOZ9x/3YdxbiHHO2depn2TRUMyriM=; b=wlREI77Kv5tJTTgr9HL98DmBRUNNcuz5jpnu/ZUQal1MwOMtWspw/OWKKirxmEJsKO AMVCVY05F/9TFYswGI3lUuK4kDqp3r4okYt2aPq/mTx8nE9C3E11hCmOwcVFeF+qgzdn vYMFfR1qR/6vH1HDSEBJRU47DJX266HGCVBtC0g9aPAArugLSaq/4EKc4Ut9OmMTJcDe H3ADVfygvVrK7wDzYoX3PlEhkQUHQhfLxYeDnrZ/URnlR5+ayLetzy5g5vfb1W0d56lc iFQL50l2LL+V80VP9p/NDR/qwH2Yb6Os5NDM9L97y+FIzPvNbBP/KFvvbga1t2xEPcCe ZCuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=TY6WrvPq; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds20si2223344ejc.62.2020.09.09.12.03.06; Wed, 09 Sep 2020 12:03:31 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=TY6WrvPq; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727075AbgIIS7K (ORCPT + 99 others); Wed, 9 Sep 2020 14:59:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726738AbgIIS7F (ORCPT ); Wed, 9 Sep 2020 14:59:05 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8601C061573; Wed, 9 Sep 2020 11:59:04 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id s13so3321959wmh.4; Wed, 09 Sep 2020 11:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uXnjw/VPfhPNUnKOZ9x/3YdxbiHHO2depn2TRUMyriM=; b=TY6WrvPqQej5Qj53qINdsFDPIya8YtQdBfgYxZLIGMmAZsCV0LErKw8IEvAfAQgL2u XnZWLOfWp/5eXDPebRMSz5JYqi0faEf2xaFq4PxpvpQc4H++KNNRgxVHtF6GvRNEZuYw 4c8D4VloFNUyQ/kkeNyiB7NqjkNm2CBY6ZqrtYb1oc/JPL6fObquZ68czZ++pO/vMB8F 9A8V76itAmfXV/G5N8ZYIp6jF7/1NK5u1W+DpFCkLI9V9F+ylmA+jij7NyRC9PmrKgDh 5pJCDZiIJ4rgth7oakgD/2A3SUoZdbJ7+54mb2+bOOLQ3QRB1ZxuJF5LSyscJ89nRZ+z tVMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uXnjw/VPfhPNUnKOZ9x/3YdxbiHHO2depn2TRUMyriM=; b=jewWnlBQXmG68rAzXDKt4b7V96MSaAf1zjz6G5gymKKUc7uXDjg21jT/CTW5a/aNWs 4EA92aHdIpCzAUzHCffqYrS+LN04/v86olmFnUzzUbB/Egg/HjDfw00q3MU8cfelNpLV b/MLygUoqXBBzNaGGueBJHSa0vx8orWbiM2QySO11vz47zEqLBPfQ/vVoYSghu6fu2BR yAQSi70GY/UWCO/J5u2JViNIaOlWOLarvVmgM3Zkp7KulpE/fog6fhPcInFjsNCy+qGg nJwipqPgX4OIxu7NOFz687XdMRfJQbU49YLMtAYU+s2XELsLVGlPNIwfKTNnTf19J2Ea SCgg== X-Gm-Message-State: AOAM533Nr2vZV7IGkj8W2gnHAFaMxXUcPdlt40WfOcsLxiKK5wI6tJG4 cPGNs5TpRqUX8dbau11gNKs= X-Received: by 2002:a1c:1fcc:: with SMTP id f195mr4663261wmf.127.1599677940990; Wed, 09 Sep 2020 11:59:00 -0700 (PDT) Received: from localhost.localdomain (cpc83661-brig20-2-0-cust443.3-3.cable.virginm.net. [82.28.105.188]) by smtp.gmail.com with ESMTPSA id j7sm5270080wrs.11.2020.09.09.11.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 11:59:00 -0700 (PDT) From: Alex Dewar Cc: Alex Dewar , Hannes Reinecke , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: aic7xxx: Use kmemdup in two places Date: Wed, 9 Sep 2020 19:58:55 +0100 Message-Id: <20200909185855.151964-1-alex.dewar90@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kmemdup can be used instead of kmalloc+memcpy. Replace two occurrences of this pattern. Issue identified with Coccinelle. Signed-off-by: Alex Dewar --- drivers/scsi/aic7xxx/aic79xx_core.c | 3 +-- drivers/scsi/aic7xxx/aic7xxx_core.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c index 1c617c0d5899..98b02e7d38bb 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c @@ -9402,10 +9402,9 @@ ahd_loadseq(struct ahd_softc *ahd) if (cs_count != 0) { cs_count *= sizeof(struct cs); - ahd->critical_sections = kmalloc(cs_count, GFP_ATOMIC); + ahd->critical_sections = kmemdup(cs_table, cs_count, GFP_ATOMIC); if (ahd->critical_sections == NULL) panic("ahd_loadseq: Could not malloc"); - memcpy(ahd->critical_sections, cs_table, cs_count); } ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE); diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c index 2231c4afa531..725bb7f58054 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_core.c +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c @@ -6879,10 +6879,9 @@ ahc_loadseq(struct ahc_softc *ahc) if (cs_count != 0) { cs_count *= sizeof(struct cs); - ahc->critical_sections = kmalloc(cs_count, GFP_ATOMIC); + ahc->critical_sections = kmemdup(cs_table, cs_count, GFP_ATOMIC); if (ahc->critical_sections == NULL) panic("ahc_loadseq: Could not malloc"); - memcpy(ahc->critical_sections, cs_table, cs_count); } ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE); -- 2.28.0