Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1195936rdb; Tue, 30 Jan 2024 10:33:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBSSZPcOIq6cXJcKMYvGQUMMaSrIqWZr/5RNAF7S5HLiKINpZtGP69O57haUYsp728B2JJ X-Received: by 2002:a17:906:48d6:b0:a35:fa06:aced with SMTP id d22-20020a17090648d600b00a35fa06acedmr3165373ejt.65.1706639634652; Tue, 30 Jan 2024 10:33:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706639634; cv=pass; d=google.com; s=arc-20160816; b=fNMeWL9GPd+syjKwKjfMM2LJaxxLSwxszkXtTDji45P2VFHSwFl0BQldCq5s/ZohZl AUZzMpESzyTd54epjWoSNQgiJx4IAdgnpZ+MbNdM0bedBcYf+ogAyqW+q/dGk0OyG8Z2 KjhuAPx7a29jWZNAEWjF/Z5ASJZOhkDc/by1lSnRMRUeHQjP2DD+KAzkYlfbJcP9ge7I 2WU9U99wTams+Nx8j87o/VoOVfpWqvRHn4aR1taLQondxzZ6IDYw6j0N1pxDGab3ieCz wlsvYx45//xhtmCd8P8Nd5GKJ1XNKmIj4SAWJkijVUCnP+027meGn3rLJ6LjzWhV/3ht 0HAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=dwMBQhKAPrdpeG07deWR0oT84VH23ARprvDaD8J62YM=; fh=5EIaN+XpI4QCUIFBDVKRedmwnil4G3qR/VzXB7lJ1yo=; b=VnTTDo3fiXDfpALfqLIUKfXsk51Y4FP5/slo4GN9i7l8KQy3UKuileeuzBaSIm5D4I zoILXomUXUpWAudtoNlH1vbtgJrmU+stz7VpszVrO/jBpfdl8ATOlZ3rg5oc2te5xAg4 8QaDrgaqF+llidW7izl+n46IoLqEQsUVTuwQktaBL/aEloo9onIuHY3iz2MvIbka/n4k o5kK8vDemYN+dOGUnbE+mVvVh737tu/o8H65HT8+N3t74UiYjnuXzNx4BH/xI3tIV0NP o4uPXLCqwb+FmBeaKsDTimQtby9XZdpm4m0FPcTNGoAIIg0ImxCQZwMopyFpyXbc8n8i 29NA== ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=uJ8MSHSC; arc=pass (i=1 spf=pass spfdomain=embeddedor.com dkim=pass dkdomain=embeddedor.com); spf=pass (google.com: domain of linux-kernel+bounces-45111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45111-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a16-20020a17090640d000b00a30fe09280asi4654192ejk.707.2024.01.30.10.33.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 10:33:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=uJ8MSHSC; arc=pass (i=1 spf=pass spfdomain=embeddedor.com dkim=pass dkdomain=embeddedor.com); spf=pass (google.com: domain of linux-kernel+bounces-45111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45111-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 145B51F2473D for ; Tue, 30 Jan 2024 18:33:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C6A5869E10; Tue, 30 Jan 2024 18:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=embeddedor.com header.i=@embeddedor.com header.b="uJ8MSHSC" Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 169B669E0E for ; Tue, 30 Jan 2024 18:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=44.202.169.39 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706639619; cv=none; b=g83lUqsik45xw/LeCHuEsvcIGchENMi9C6dHh6Cq2oznZ2myXT2p1aZdl3/kpWdZ00Y+trU7LkvpuWqx2Bb8Wa95a5CMOEWF9Jsb4pr2cbWKD3xvyv9kS3cfhE+nnYH19qvynI9OxArtRY0D3pyb70w2UoN054tvVfV4c/6n1zo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706639619; c=relaxed/simple; bh=e6Em/YoU24DzfrgG1I3MeTPrdt0H0Tda436ZQlrVs44=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Q8hqabd+mbpYMudOp3gbnP8BLjrFhChJZbn4VZBMlysO5ulKy3PESg4kf2IvjNu7pCexxThovQB+x33/evbtSLQk4hrL5N8TBJNGUd79np8N/HRwuNuKZKS2vIYfEjcKi/YUf4Lj/c2JWk6ICgGBx7L9VB+vOAqt0b+YfPrXcwI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=embeddedor.com; spf=pass smtp.mailfrom=embeddedor.com; dkim=pass (2048-bit key) header.d=embeddedor.com header.i=@embeddedor.com header.b=uJ8MSHSC; arc=none smtp.client-ip=44.202.169.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=embeddedor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=embeddedor.com Received: from eig-obgw-5008a.ext.cloudfilter.net ([10.0.29.246]) by cmsmtp with ESMTPS id UqblrV7cRTHHuUsvNrtWDe; Tue, 30 Jan 2024 18:33:33 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id UsvMrAvw5L3AmUsvMrKkDm; Tue, 30 Jan 2024 18:33:33 +0000 X-Authority-Analysis: v=2.4 cv=Sdrky9du c=1 sm=1 tr=0 ts=65b940fd a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=WzbPXH4gqzPVN0x6HrNMNA==:17 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=wYkD_t78qR0A:10 a=NEAV23lmAAAA:8 a=VwQbUJbxAAAA:8 a=7YfXLusrAAAA:8 a=WIj-IPmD8QUj2RxniLMA:9 a=QEXdDO2ut3YA:10 a=9cHFzqQdt-sA:10 a=PUnBvhIW4WwA:10 a=AjGcO6oz07-iQ99wixmX:22 a=SLz71HocmBbuEhFRYD3r:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dwMBQhKAPrdpeG07deWR0oT84VH23ARprvDaD8J62YM=; b=uJ8MSHSCsIUsxGqykVEA55n+V3 6mCCY8tYHJbdm9YTHC5fNd6sP8dvh31H/NILFDuLOJDnI6jvXxq0hP2VfSPmv7AADYm5pRpZxyMFw UeypA0zLbJi9UxTXSBlnQDSnFTJWyYpcaD8pet80lVr3/rPueJiR1fnFMxFqkbWl+PWSG40xQ3aPf ZEl2sVXOoVASg6qC5bdaRKlUdszbFa/f+6whfGbz+vNOgDNqufYKBMa6Uj+ApsZUxZ2oRHYT5GNk3 ws2lKbFPLtp7vH2jk/9sc7VytpiZPLO7jfCrdTOH1F0I99eHhasGDG1tXk2ne97Brn4366suqAszH DBbmewqQ==; Received: from 187-162-21-192.static.axtel.net ([187.162.21.192]:52948 helo=[192.168.15.10]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96.2) (envelope-from ) id 1rUsvL-0030Gq-2d; Tue, 30 Jan 2024 12:33:31 -0600 Message-ID: <114074ef-7021-4ca0-a5f7-b0ea37948f5d@embeddedor.com> Date: Tue, 30 Jan 2024 12:33:30 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] dmaengine: pl08x: Use kcalloc() instead of kzalloc() Content-Language: en-US To: Erick Archer , Vinod Koul , "Gustavo A. R. Silva" Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20240128115236.4791-1-erick.archer@gmx.com> From: "Gustavo A. R. Silva" In-Reply-To: <20240128115236.4791-1-erick.archer@gmx.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.21.192 X-Source-L: No X-Exim-ID: 1rUsvL-0030Gq-2d X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-21-192.static.axtel.net ([192.168.15.10]) [187.162.21.192]:52948 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 2 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfD60vF061QhTTMEdLo1m+I0nldcoi2uR93Q2rTFCwtROWLlaY3HrtP3qEPjmGNnyvS0rHUoDUDbaYSKShnaOuc8qSvRCMmoGFHoZwqJN0Tn4WO00e4Rv WP+3BcD7o4YAYYzIANFl9h/th/eNkBRrOgjiADrzvdHkHFVpnrDTD1ZKZ/uNLsPxYePKv9p1B6/ASIW3cXvQPfRlFjCY5rczwcb64HKgk5MO5x5MfOHVCHKs On 1/28/24 05:52, Erick Archer wrote: > This is an effort to get rid of all multiplications from allocation > functions in order to prevent integer overflows [1]. > > Here the multiplication is obviously safe because the "channels" > member can only be 8 or 2. This value is set when the "vendor_data" > structs are initialized. > > static struct vendor_data vendor_pl080 = { > [...] > .channels = 8, > [...] > }; > > static struct vendor_data vendor_nomadik = { > [...] > .channels = 8, > [...] > }; > > static struct vendor_data vendor_pl080s = { > [...] > .channels = 8, > [...] > }; > > static struct vendor_data vendor_pl081 = { > [...] > .channels = 2, > [...] > }; > > However, using kcalloc() is more appropriate [1] and improves > readability. This patch has no effect on runtime behavior. > > Link: https://github.com/KSPP/linux/issues/162 [1] > Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] > Signed-off-by: Erick Archer Reviewed-by: Gustavo A. R. Silva Thanks! -- Gustavo > --- > drivers/dma/amba-pl08x.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c > index eea8bd33b4b7..e40766108787 100644 > --- a/drivers/dma/amba-pl08x.c > +++ b/drivers/dma/amba-pl08x.c > @@ -2855,8 +2855,8 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) > } > > /* Initialize physical channels */ > - pl08x->phy_chans = kzalloc((vd->channels * sizeof(*pl08x->phy_chans)), > - GFP_KERNEL); > + pl08x->phy_chans = kcalloc(vd->channels, sizeof(*pl08x->phy_chans), > + GFP_KERNEL); > if (!pl08x->phy_chans) { > ret = -ENOMEM; > goto out_no_phychans; > -- > 2.25.1 >