Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp287150rdb; Mon, 22 Jan 2024 22:16:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVgI5v/kCh+bPBT3pLyZ4jiAgUw9mD7pDAGlOVeJ51ONSRtmu2bVNKq0gfSFuKR1fqFpIe X-Received: by 2002:a05:6808:1829:b0:3bd:c75b:dd8b with SMTP id bh41-20020a056808182900b003bdc75bdd8bmr255179oib.38.1705990565657; Mon, 22 Jan 2024 22:16:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705990565; cv=pass; d=google.com; s=arc-20160816; b=AkHOnGnc8s449GJWhFUAOJsPX2sQf5QRX9mSVQgbyL1pJm1Kd2D4l20da2qyQ8/V2n tkaJi0VxLCovbk3WxKm+WWx5qeLqh+xf/IdgpZ4QGPbJOrB28AH3t3gObrpbpShqGK2D PzdaqFlfR6CogjhbY5pZ0RM1jHyCzUawR5g1P/nplqLTAWHgqc3NIPBsSDMwEZbFFcC/ SUtozsDVdRbBoo3qvPw+cKiG9ITN/4aZsdNPXWvVJ58Q2rnQ1GWS/OGjNVUHYLvVs6z3 67V2mN5jHyqr5+h+D+rh5r7tj5kX7fFNjDnbiAM6wXkjMvw1Md/veFbChATtBWjchGWm rd8Q== 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=ohXdSRWKpjp/SSHD5uSCqu3QqGgmhGSWzWcMPZ6VRxw=; fh=dW8eeeLtBfw3iaTxm1GmBfd0GAq3oMP9oArUqu4V4FI=; b=TDVwNoA3bCqUNHk6DDg0EYBT6LSQTK+mdAZzFE5HjOm+HOGlKG7mN/WGGVZruxakFf sLwT+WMJmJPjsv2E5UYLwiwDqYZpLLLPdM2NnaWMaHc1PisdogvBO51bDLLathRAkFIU fv/DDkFMBsIqZV87LfVnfZd5KXrgnCySrxE7tHZT/wUfB7M/sYRuzg4efh9OJu9CWgL1 nBdb4Sg2AxiK+azNZ7t2cIwiKWdSpVH9brHq71/qqPfOGXr90agpiePDQBPhheGb6CQK jNVEp5w8HZZIMyMaxpqyfmp1v3bK/IM5SekO+CQq7olg5LxU13st9+uEGRKEsjibd/t4 tXZA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mRKnHnkl; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-34755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34755-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n38-20020a634d66000000b005cee179d5c4si9121609pgl.230.2024.01.22.22.16.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 22:16:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mRKnHnkl; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-34755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34755-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D2A46B210A8 for ; Tue, 23 Jan 2024 06:11:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 955AA4F88C; Tue, 23 Jan 2024 06:11:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mRKnHnkl" Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE6914F880 for ; Tue, 23 Jan 2024 06:11:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705990306; cv=none; b=Z36yvhWXDN90lUUco36VrN9S3gCUjkErwuXoxR6Mb6em+iQExytYD0RPSg6oIQLpHbOW1AmKjENAT998dbx96V/S66t9WS7sP/xcwNUVkOvzyBBCCXy6csYd4CG9xvlDHWzZvcZSANIPigbs7qPwqDzyME0hgbrpDcRTm3+yfZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705990306; c=relaxed/simple; bh=CN9XP3IqMW/054i/SszfD8BegSj621QjpufQVB9yQaY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qNhHkwWHAYob+07LkAu77JgnchtN7MmgQT9Q3Ds53FCqNkshaRdnM886zEl5d6Mk+/iRlWLx6bXe7X5OG1JAYWfcFsw6zoMfpw484Zp8kpv4SW4R7FwlYrcFKpqKDdM/2DGoCKk/zwcuGIOYIPsW7WbECcp6UG3JlTOtNAm7O+g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mRKnHnkl; arc=none smtp.client-ip=209.85.161.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-595b208a050so2446205eaf.0 for ; Mon, 22 Jan 2024 22:11:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705990304; x=1706595104; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ohXdSRWKpjp/SSHD5uSCqu3QqGgmhGSWzWcMPZ6VRxw=; b=mRKnHnklKFUemg4aOxXYjyGWTrQH/3qD8zcCSSXfoE1B2cYIvm+igDGaowY9BlUM0h am0WaTWle50a5c8t/DvazxDFGQNXQf41oN3pGLly7GC58lS3LqHn2GVB2ld4efBuFpDQ 1iroC8oFUkLfGsazNAzGIgfUfHt4qQrECVbUZ0M+BPaxgw6K7FO8/XiR/xqbh3CZABxE k9F1LaKTmxuLux0qSKBHKIwovYHjXp4z6MzAuys2Ffd7BQc9fAIROVJpchmffqd7rJ07 UQulMGM0YcumWXdwi2ws3cIlo5nhfIKqI/fKccPh9Xp355IUe16X3SAP53w5NmAttUIZ cR4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705990304; x=1706595104; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ohXdSRWKpjp/SSHD5uSCqu3QqGgmhGSWzWcMPZ6VRxw=; b=CIQs2uW65Xbo6zfiUXAtPIvPNQGrXX8/Fzm9/1yiNoQIRuE6kYG8SMtZR+N/noJnqZ MA35Pzs/u+RregLTM5xk653ubf819theoG8ETNk7getEvBTNjP3bSQeP9JluKd/5zREi sxkCCNlqE3mPEhjeOXFDDwmxFvH08oOR4pEj9xExdyB+TATGKPTSJwS6E49KscbmDvsG /w9fGNSf1mCd3t/vOsZzffLnkIoBYO+WU0fYRs/fvPBbdz+r4+B65SBerL2fvs+XWCMD 2Ih3ee/CRlkIWYoHIDwiub9+o8v0/SMhZJhPRdcNHsUTyx2nUOIkNWd3H6+diowG9dKU kMFA== X-Gm-Message-State: AOJu0YwnhfFrjG9B+Q6ZBu/EOA5lI+vrDlRtPOepp2XSCs7A9Cdv2cvj DE9hDMMGKx+aaEYWydcN0XEfVboPvx4Qfh0Cm9n/9+bplFLDlHAhnxq7n6HpwkU= X-Received: by 2002:a05:6358:52cc:b0:172:e227:bfd9 with SMTP id z12-20020a05635852cc00b00172e227bfd9mr3703228rwz.42.1705990303944; Mon, 22 Jan 2024 22:11:43 -0800 (PST) Received: from localhost ([122.172.81.83]) by smtp.gmail.com with ESMTPSA id r11-20020a056a00216b00b006dbce4a2136sm5191749pff.142.2024.01.22.22.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 22:11:43 -0800 (PST) Date: Tue, 23 Jan 2024 11:41:41 +0530 From: Viresh Kumar To: Erick Archer Cc: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , Len Brown , Pavel Machek , Alex Shi , Yanteng Si , Jonathan Corbet , "Gustavo A. R. Silva" , Hu Haowen <2023002089@link.tyut.edu.cn>, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2] Documentation: power: Use kcalloc() instead of kzalloc() Message-ID: <20240123061141.k5wf6r6gn3w7qk24@vireshk-i7> References: <20240121104344.5001-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: <20240121104344.5001-1-erick.archer@gmx.com> On 21-01-24, 11:43, 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. > > At the same time, modify the translations accordingly. > > 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 Applied. Thanks. -- viresh