Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp2011525rdb; Sun, 21 Jan 2024 03:45:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNOcucEuiKosPyT6DddtPtroB+qvpWK3vQWC2NsHkLi0dhc/UJgxpsT0YUSdGxNBspOxTc X-Received: by 2002:a17:907:874b:b0:a2f:b9c0:9c45 with SMTP id qo11-20020a170907874b00b00a2fb9c09c45mr922431ejc.28.1705837505171; Sun, 21 Jan 2024 03:45:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705837505; cv=pass; d=google.com; s=arc-20160816; b=YFEI8315ioIJnkYGEpNH60jTnus6UsYHnvVzAAeqRqD/5StlTCWNZgQyfHbyJUQa7w SSITdXPmqHOWiFhDJpMUgxpQ/aIiJ1LrZL2my10DMQokefUHR9qrIn7chVaMGbRTgLlC wOKIVK69vdduO105UxOfXvzlRbAubt4qrIbP2TC9qdhXTPGhEah2ip1rKpw1nqvrAUCA 139FWp2uHiHY9KROYtz7vouZKFWbEwP+GepFYMJdKmwc3ExTrnvd2jK3iffxDdMi/WJo 7/+d43pksQDuPeCoYPf73DlCKdqP6BiHX3oeS3XwGqxErzLGLUADlxd3our+PG1vIUsc wdgA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:ui-outboundreport: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=/8G1IJ4HSmsqePWNmoZdFJ3sSF3xLCfuw7T4WgF6sUA=; fh=n05UOPRed6oyvORMVk6qoVwCRXMWanMSqKtCXmS88Es=; b=TjohZT59GUoAWpPfYeKOAkMKbZaNGlWR5m+naPnSJ87HzrGLfRqjRh6s6Eg09yfBc8 GJTPbB8/KVc2ft5Z+HTwxV50TdeP0oHD/ln9YlWnFxjIf+TbfYvDEMRBVGSrSUVP7yRh qqxI+8Rip8Em7qv+97i8IiGo9CITLc0SEU/pmc1VvFLVcLfUBmld36nxmmC7R/gGDNgS FRiHBw/+4m1wZkzP4l00OTndFFrJiGnHLHSg9XKwh6b5ltr8VEJrlG6OCJ8IV0n5bLqJ iKYSHY5TkK1XLq1uSipPgUeTcQy5U8Iw7e92RkD21EO7a89Z6MhrgX32+kVwx/i+O22f nPEQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmx.com header.s=s31663417 header.b=dUiAyyKm; arc=pass (i=1 spf=pass spfdomain=gmx.com dkim=pass dkdomain=gmx.com dmarc=pass fromdomain=gmx.com); spf=pass (google.com: domain of linux-kernel+bounces-32033-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32033-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t13-20020a170906178d00b00a2c69abd863si9495457eje.752.2024.01.21.03.45.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 03:45:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32033-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=pass header.i=@gmx.com header.s=s31663417 header.b=dUiAyyKm; arc=pass (i=1 spf=pass spfdomain=gmx.com dkim=pass dkdomain=gmx.com dmarc=pass fromdomain=gmx.com); spf=pass (google.com: domain of linux-kernel+bounces-32033-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32033-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.com 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 E79411F21724 for ; Sun, 21 Jan 2024 11:45:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D1AD36AF9; Sun, 21 Jan 2024 11:44:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.com header.i=erick.archer@gmx.com header.b="dUiAyyKm" Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (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 0B3D4101FA; Sun, 21 Jan 2024 11:44:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705837494; cv=none; b=L6RhmHEKROdvei/dIfhGl0mx3tTyNtrhPu2pTrqLPjVwJCbyrNCBPbsDwh/59wTLL5YzJX8YOeJfuXdo1s8ytDsIS3R4kCh7ZmO9mXFzELqYHuRwxpDVbYgT6JLI+l/cK0Zf41D5pYBOqjHnirGXsU+v/AwavIZxDUeBalY2UZk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705837494; c=relaxed/simple; bh=/iiOZBUIKMJCyS5qs36JSqDPr7q1cQvorRERzDAmJws=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cCn48S4JKTT+6GWPcpIkzJtcWsAk/9Gi8WfHoxGURaMMtmuksj4ySqJcDNsS+h9AcJrJhlWTDTmt+dpd/hptUzErPnxICGpZvKprFVKhwBGUjWgCLFHw0TxFfouy4t5sa8SY3cVCneOR87FAQTgtYlW54ydhLPAtRqdzFMAFLbQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.com; spf=pass smtp.mailfrom=gmx.com; dkim=pass (2048-bit key) header.d=gmx.com header.i=erick.archer@gmx.com header.b=dUiAyyKm; arc=none smtp.client-ip=212.227.17.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.com; s=s31663417; t=1705837475; x=1706442275; i=erick.archer@gmx.com; bh=/iiOZBUIKMJCyS5qs36JSqDPr7q1cQvorRERzDAmJws=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References: In-Reply-To; b=dUiAyyKm+7gZQqEs7jaFs8x2W/DQfz0f42OP+RJ5/2PMssz43v68EW6iaqaFtYaG 1LawT22uXpek1K16Y+CBN9MHovfEP+GtkAKAZYY9YDkDJIZVvcOzaeX8LyHriyEOU rLcqVJ0ysp/bgQOoTrEf00drWm0kS60ft3td5ysSOBYdyLHl9DAzuzlkliudIfxm/ WTHvpt2l1UpRk0uSMBj77tke+pkb+B4plcGN1t0y4IgC5ys1MnwR5IwGKfDBb4quk n6NwcqF63eMJrBFU/PQY50bcpxOJtBpp0+f4ltEkjGDZne+fcwVtDPViqsn+jpngh trGvzLpntWwe3x2JaQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from titan ([79.157.194.183]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MacOQ-1qqoaf051u-00cDUT; Sun, 21 Jan 2024 12:44:35 +0100 Date: Sun, 21 Jan 2024 12:44:31 +0100 From: Erick Archer To: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , Len Brown , Pavel Machek , "Gustavo A. R. Silva" Cc: Erick Archer , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] Documentation: power: Use kcalloc() instead of kzalloc() Message-ID: <20240121105143.GA4546@titan> References: <20240120120527.3866-1-erick.archer@gmx.com> 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: <20240120120527.3866-1-erick.archer@gmx.com> X-Provags-ID: V03:K1:cdmaWmbYoa/RJ2JKUL9HvdAuGmTiRdeyO/6pH/NsKM1VPkMfiVe zNCJ/FMQL313OPf3HK3JFf54Ee98zj09IJEPBtz7nSTdhhAyqRIH91H6IBgJmmFdxiGhwOO 3tTmG8UtCRRkLFxPU0RFQcfef18OIGFz45mXwJDdiUu/zkklKoimC0/DSuomBNksz0hvpoG EpGHa3wUcydWaknK7XPgA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:rERkRzJHHsI=;z3yEKJpJHmLXTIz240asfeTKJ5M p0RBSc5bFwhpJDdkmwWDSxCtDWe772+ijFYA6gHVXjU1c7UO0KBOBvsygol8S9kkTiA6SMKXu KbBdmW5zL7f1vl+xEPBOR1UaSesQcAMNguD+/q1NJxihjuuyks4iqhJP8NtUxSIGbu9hBxCC0 KAc+zLsErk9qX+5FqU5EJ9H58oYe/QK1vcO6/1lHOPAPzRBYUPZPEABcLIXLpY2tycRsKDT4l JQXd2oqEwpvXjvszagOL6VZCGjMU5bXT5TPk/1pH6C3K5XPDe+0FzV/j7gFPEMmVJ2RSkxz5X 8E8+x+6j7rHZ0gQK6GbjPV64U1YeKVtPzlk9AEs/Zu6P37r0LLS5wu2ebnnLpln+2xQIjNOMA 39ub25PsstoyU/mDAAQR21Clg2fMoqgmRndD+ptPExwRbn2yPlLMFlnfs1s2achgxifzbYMS+ D2CHIG1u6obuzReOCDELsLboJzyxFEbYyx51huSfgcnr75JEM3IV/BXMuM/FV3GACEsN9/+90 nPEY1N9T7xZLmCrd7PLCq4W3weEU4u28zmnHu09ujkuiyDCyQ10SON29xpfjhnmgmcOsDJtm9 tjhkmGmU0Qf7BSN0LtVsX5xtIaX+3JTb57/k1TshCE+/GQaqUH4Z3+PkticFr+EvlHZoR5GtN SXaumvWfM6m1YnCoPvr2gvCsHCgLCFo6AZORCxlBj7Jbnl+KJF8nJh17b/0KDJ7rdFSQm/8A4 umEkVhud8+gp9u0ftgyvBTa0CmFp21zcn4t0RBIgGqWcrdbTWNFQGE1z533XvkPrHevClwKEz vrJXuaYWLyyscqSee313ij6cCwwU3WZwMmcv6MvFiH6i3g62EykLaq+4F2LBFnrY/bargJ2+8 xfPM8+wlkPnDLfHn7fCGs4GkgBgSJSOtuxXsdQznZmfklTLFGfWYgmEbx0P2WpQcsmuSY4eAk ZyOyR1unEgqIaTUXYfi58EpNs78= Content-Transfer-Encoding: quoted-printable On Sat, Jan 20, 2024 at 01:05:27PM +0100, Erick Archer wrote: > As noted in the "Deprecated Interfaces, Language Features, Attributes, > and Conventions" documentation [1], size calculations (especially > multiplication) should not be performed in memory allocator (or similar) > function arguments due to the risk of them overflowing. This could lead > to values wrapping around and a smaller allocation being made than the > caller was expecting. Using those allocations could lead to linear > overflows of heap memory and other misbehaviors. > > So, in the example code use the purpose specific kcalloc() function > instead of the argument size * count in the kzalloc() function. > > Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-= coded-arithmetic-in-allocator-arguments [1] > Link: https://github.com/KSPP/linux/issues/162 > Signed-off-by: Erick Archer Hi, Drop this patch as a new version has been sent to change at the same time the translations. Thanks, Erick > --- > Documentation/power/opp.rst | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/Documentation/power/opp.rst b/Documentation/power/opp.rst > index a7c03c470980..1b7f1d854f14 100644 > --- a/Documentation/power/opp.rst > +++ b/Documentation/power/opp.rst > @@ -305,7 +305,7 @@ dev_pm_opp_get_opp_count > { > /* Do things */ > num_available =3D dev_pm_opp_get_opp_count(dev); > - speeds =3D kzalloc(sizeof(u32) * num_available, GFP_KERNEL); > + speeds =3D kcalloc(num_available, sizeof(u32), GFP_KERNEL); > /* populate the table in increasing order */ > freq =3D 0; > while (!IS_ERR(opp =3D dev_pm_opp_find_freq_ceil(dev, &freq))) { > -- > 2.25.1 >