Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp798125lqe; Sun, 7 Apr 2024 04:39:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCBw2fxaptImx5vf49uRHVfrgfGN5X21+3BbgD9ofqcRP0F6BoZE/iUQoB/6ZnVGq+++BUYS/Kopg4KjjeE4ckN4oyRiDxpl3G1C9u/Q== X-Google-Smtp-Source: AGHT+IFUIUxdidyjcordw6Ab5oeHyQVjtZrACCW9mgzMAdCkpKdTs+h5jD75IrCyCFD1b9sA4WWf X-Received: by 2002:ac2:4355:0:b0:515:ab5b:a45f with SMTP id o21-20020ac24355000000b00515ab5ba45fmr3670990lfl.40.1712489992161; Sun, 07 Apr 2024 04:39:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712489992; cv=pass; d=google.com; s=arc-20160816; b=dBYOljbK/s8GXW5AtsIOo1Vr1v4kJH36mWbeZmhm1AzIdGK83j6rhco+Y95vF4gUQ3 udkunNeOCakwQB8r6Qa5eQTLJe4Vdc455jtYZEFTPig6aYW/cjiEUrOjNdEX+f3ECC8n lT1jBeOglwVlING0AJV8Az44HHgpvzMwErRLM4SaxcWFvldOLW+fkpZFs/ZaJeBGx4JZ 56ihWVF6w0EknFv9ixv+2WXy1AtHlsV2l2bU9cChUh/q8DFLCQW3x98eeRxQy9CU2njV 6hLbUcGnGJB2ZQeY7oQYaBuuLUzA4l356MHjw8W++Q2tR1/oF/uzaU1wQmxWVyV8gPhB wecg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=UCmVzsgno2KXUsf0UlVR5Sk/cWpzXsbU3lDueJQdJVE=; fh=vW20J8gPjyOcX4uYQ5NZEsWr01NFptK9iQ44HROhwqY=; b=u+rx7aSGqOKk2rLVk83muNY25CsQ3ckYb7SJQHZl5dMcqgTArtHs2Vp5QBGEDPISDb Qe2hoSRSGSQQtBf4ZCerZuuWw4FeEXxg7nTDzsdtMkI11QmHlvbejoKILYugVdR46L8X tfP46nwHACfwagpxhGAuPZUodsSqMMhGpYHqMAJZuHalCBv/r0S1aUHUB1LL4DieFiQP brQEZI7OlgvUrQU2SrG3n2F7COGcnG4oYFPTmeBmpgw7EVXvcARMpnoooH4RGPEuh1VH BrdAmLPTV2JdnwD4J1eiKn6NaElrkpcIlK6uO8Swl/Jci592VBXQEcSdC5qSW6YyezJn X8aA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZQPlKr7E; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134359-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134359-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id rh3-20020a17090720e300b00a51a3d1fd93si2646188ejb.1016.2024.04.07.04.39.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 04:39:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134359-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZQPlKr7E; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134359-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134359-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 CFB0D1F21826 for ; Sun, 7 Apr 2024 11:39:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6EC0F2209B; Sun, 7 Apr 2024 11:39:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZQPlKr7E" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 896AE13AF9; Sun, 7 Apr 2024 11:39:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712489984; cv=none; b=DXOxNTg1qxOoh4G4hhxHcGm23AjfuK8lDI3ZlFvFzLbWuIY0+iHSuQ3DRAQFB+jdewqYTGELSzXRGmuYLi7g/FxwTPFlvVv+74/VkeaYzbWpucQwkmpQRqKi0cbomO7j+yIl11iBkkCBaDUhqVAJxDVVg6RXwVQOEpYstLBXOsA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712489984; c=relaxed/simple; bh=mJvXZdPEdNoOY55fKxIUkLDgBSNeblgMJBqWySQZXys=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HQkOyE/mLzSvV5AuPBe/2bLkxbe0aeDfFiwXSxWer1QQlSRNAowG1jk5lcfWWDZ8qJy4OH3V3rGOKvCbgEK2OrIV2hrCF68c/h60Uu2NXv/AP14dzSbLaDDJs1ghwOoEmxOGJunseEkS+4BqalEw9iNQ3pQDwHesjD3An1WZgxI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZQPlKr7E; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72E0AC433F1; Sun, 7 Apr 2024 11:39:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712489984; bh=mJvXZdPEdNoOY55fKxIUkLDgBSNeblgMJBqWySQZXys=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZQPlKr7EE9d3uDNk77hg5lNwDUrEPaiPxen6hvl9nSPE1O5lH8sg5NQEcScS3zVw0 pwR6uBmifMiqMCDMaAMamOj/8RfI4fgW9zSRaPTAIHtwWkn6U4UWCoqy1NuAaHVg7Q WYbttC8d2/0hSpeT7n0fFMSwgwaC33vIESKIFMxRC67Gg8fvvSnkbTA/lEWFVcqmmN WiYmyz9I22A6hOuTGCY9oONZ2JbECAefM0O6fzC6rywe45sQRcN7AfjiZs+DAU8fkw RQrf6zVkXxbUMy0t5SoqyPK+Mo1pYDrxQZFwMBVljMMx+uPpKls3NauU9y3e/ZqIBw r2zVUFZXB7+NQ== Date: Sun, 7 Apr 2024 17:09:39 +0530 From: Vinod Koul To: Erick Archer Cc: Kees Cook , "Gustavo A. R. Silva" , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2] dmaengine: pl08x: Use kcalloc() instead of kzalloc() Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On 30-03-24, 16:23, 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] > Reviewed-by: Gustavo A. R. Silva > Signed-off-by: Erick Archer > --- > Changes in v2: > - Add the "Reviewed-by:" tag. > - Rebase against linux-next. > > Previous versions: > v1 -> https://lore.kernel.org/linux-hardening/20240128115236.4791-1-erick.archer@gmx.com/ > > Hi everyone, > > This patch seems to be lost. Gustavo reviewed it on January 30, 2024 > but the patch has not been applied since. > > Thanks, > Erick > --- > 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 fbf048f432bf..73a5cfb4da8a 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); How is one better than the other? > if (!pl08x->phy_chans) { > ret = -ENOMEM; > goto out_no_phychans; > -- > 2.25.1 -- ~Vinod