Message ID | Zcgoighe07IahAV8@nixos |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-60628-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1733715dyd; Sat, 10 Feb 2024 17:53:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzwsve89nATjkmhy/ho7xVRU7mwDLouxkXUxo2L+YxKYpngeJdxx3K95KtGk+tOJi7S2V3 X-Received: by 2002:a17:906:fa99:b0:a3c:369b:a6d6 with SMTP id lt25-20020a170906fa9900b00a3c369ba6d6mr1986885ejb.6.1707616414093; Sat, 10 Feb 2024 17:53:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707616414; cv=pass; d=google.com; s=arc-20160816; b=P46fSDvT0eSWjDe1flPQKeQfjY68ZoDwVbLdQwygOfT5gptvbAB1yDbBpj5ivlzl9w oEue7TrmfICQfJA9jJh7W3FaKG0NnYKtVZmhATL7mcbXzZ7pzEeetPtyxdR+jwP40xUD n6XJdiEpvXqR1+YD4omYcHUSxnpx3Auv/YonOeSX+1px9jQ0PcivQQjQRNpwl9pHN28k Dm4Cag2RhLBFKUPr1z2i6sH0FoAA86LP6Imx6EUpT64m6FrEKhL28FvevZWTH8gH7nbJ jtQqsQbd7hJSunYQxfct1y/J7je71K/XLy62oYcI86EDhhm4JrVtDsoN2Gi5lgvbbYCW gA5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=P1jV67d8m24PXZq1850zcH4U3UHNFlaMaq/fIupQAUA=; fh=YbKHpIm8NTGF7pIDPf9V6E7MZFDSSLNLYinRuKSsDcs=; b=sXO6fMKpNmNWSWxEC4yr3PHhM+WaziAtt8prsYEo+W5aDmoVv0uc/uDP6g6HxxpzrU +gmWIyri0NwdmRoBP0ILcrrC0eiqLKYFSmM2TTXclLIGJAF21tApBV6YGwDIWR1O+2oA JZLw0bLh09ze5EHM6Uu103bc39bN3XyMoak242stJESntfKEwC61fcRexDAHTz/H+Pgw Dzpk8aIA9BYJuvevIs2zZt00bsOxOlIS60zVXtoTfFmjqa7capARnP4jayeTHp/aFM29 qj/gT6vardyGfarlYSYT/oshstBrjQ5Ae0PAwlrJ1Rv9S5Z5d6thP3zhbTtk4NVv0FML 801Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="VCy/MYyQ"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60628-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60628-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWbkBYNgGwMyOAczOM6D2+RpN+rPWtAWWcfINXQL9oUhNAgT4YIKBb/qsmfj1UP/cG9xvi0FE4v7meiHN+9ZDxmIFQIQA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ce18-20020a170906b25200b00a3c5f12d193si410532ejb.715.2024.02.10.17.53.33 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 17:53:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60628-ouuuleilei=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=@gmail.com header.s=20230601 header.b="VCy/MYyQ"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60628-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60628-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 9B4D51F23A6D for <ouuuleilei@gmail.com>; Sun, 11 Feb 2024 01:53:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE29D210F; Sun, 11 Feb 2024 01:53:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VCy/MYyQ" Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (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 D350915BE; Sun, 11 Feb 2024 01:53:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707616398; cv=none; b=QeB+7K8BSwogl2lW3JVQY/5nb9rxNdGMv6hUX5DTLkwvfWwTx8kg463/HDPee2/dZaiImczabTneXS61YMRYYSpMK7ZEAF4YDaitDkPzCOGMu4BOW3iUW6JB4noNFJO16zYUXJQcsNZluWZmqaDt7xbMl+zh/XeXjPesNhmEBYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707616398; c=relaxed/simple; bh=nuSzSl9gWOU7ThKVhsz/gLgGzU40+yE07LZq1v68Oyc=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=sIb5I4ZYv2IEq9/NK9jdu5D3ffJIWMFRuF2mW7dJZyLNBz3d2mxG0VGY7ZxaFvDQWPjBnWcKJoTje87ossUkKjhP333eFJn9ghEovv9xNcVVOTcDfaYgRNijlh7K9Mz9P6cUfe9r7Po7/i3PIuJUrKfMCsJZEwvtBP+cLyuY23o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VCy/MYyQ; arc=none smtp.client-ip=209.85.219.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-686b389b5d6so9487246d6.0; Sat, 10 Feb 2024 17:53:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707616395; x=1708221195; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=P1jV67d8m24PXZq1850zcH4U3UHNFlaMaq/fIupQAUA=; b=VCy/MYyQU+vcRyP6KfaJDM4e4frRffsi4M89h5jxeKJyE/idS/8UH2toVweA3Ew3dv tvcEToMmJfE2Kf61Bds1w2/v+KqwslUprDQFn5kobKKu/2H5+kkCa+nAILdI3nhMLcWk pVqPolRFuTi+zHLBJyUHSw7VamUcXC4IKMRBVYz/21ZGBgDc7+hIi4fkFcMk1KmMVvAW eFrl5fr8CjuoTA5Osp6RX823oDoB6DdcQ8T+EPQ8ePJV0J10MLiAstqIwsWp7Nkw/V3O Gvcl8uvvemjoZNseXCi3EiaQIOvVk/fxRdf5gMJ8HxB2LWQCBqeqYNRN7AzDDXqCJeM4 EwEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707616395; x=1708221195; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P1jV67d8m24PXZq1850zcH4U3UHNFlaMaq/fIupQAUA=; b=uZ2eeKLkJ8Z9SMLxftBGw41cQc/3SZtyNvowPyU6jvBSm8AC9JZ6ZM6VbVI6rb6e4G +nQCnZS6voIfbVJv7QbLDDwcyYmsa5tRHr2QjeiMgMHKvB3w5wiitrUsLF1nCkQU2hn6 tI2W9FM/uIiHHlnVRShGcoUfqaTWPWusFuJX+Bvmq+cyRmVWFDZ7zRnnHWeLJ4Cavj++ Q31SCU+uXkVYnvOIktI+STai++mt5ibo7DwRjMaANSPil3v98AAERYhd+pOUBu8vYD2s 57X4bJY9HZh12WzUV++K0mpi7yntEwE13Kvy2h5BXZKqSfzygWIMtvGUQfcnN4Dky/Gd nQ2w== X-Gm-Message-State: AOJu0YwTIovF2PLFrqFEi06CrrRqJADCivtd8HcFEE3EcEw1ReWJn4g2 6+ORYP9p+T4BDxgzK7qELNeIcHxAI1jz761OweRF/D3mlwFzxxrI5ur9+P/UeA== X-Received: by 2002:a0c:dd14:0:b0:68c:627f:ed53 with SMTP id u20-20020a0cdd14000000b0068c627fed53mr3608896qvk.59.1707616395646; Sat, 10 Feb 2024 17:53:15 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV6O9Ebb21G/lrlgwem4+12w8w/ssoqnMBcmAlTA9/i7CKwYyO3yj/QoX0Faoum6H5Nkw2vH94Wf3fg5FDvLQEJZEqqle0mPfhEFd1PPREyOP8JHzxHt3gz62i7mRAJ+cE8u9Fzx/sHjNWoBqj9C3AmG7KUsfkMLKRnyqLoXBOXrCZYUMM= Received: from localhost ([207.181.197.26]) by smtp.gmail.com with ESMTPSA id mu19-20020a056214329300b0068ca3ed8cb1sm2285785qvb.73.2024.02.10.17.53.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 17:53:15 -0800 (PST) Date: Sat, 10 Feb 2024 19:53:14 -0600 From: Lenko Donchev <lenko.donchev@gmail.com> To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>, "Gustavo A. R. Silva" <gustavoars@kernel.org> Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] fs/ntfs3: use kcalloc() instead of kzalloc() Message-ID: <Zcgoighe07IahAV8@nixos> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790565588796835993 X-GMAIL-MSGID: 1790565588796835993 |
Series |
fs/ntfs3: use kcalloc() instead of kzalloc()
|
|
Commit Message
Lenko Donchev
Feb. 11, 2024, 1:53 a.m. UTC
We are trying to get rid of all multiplications from allocation
functions to prevent integer overflows[1]. Here the multiplication is
obviously safe, but using kcalloc() is more appropriate 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 [2]
Signed-off-by: Lenko Donchev <lenko.donchev@gmail.com>
---
fs/ntfs3/frecord.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 2/10/24 19:53, Lenko Donchev wrote: > We are trying to get rid of all multiplications from allocation > functions to prevent integer overflows[1]. Here the multiplication is > obviously safe, but using kcalloc() is more appropriate 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 [2] > > Signed-off-by: Lenko Donchev <lenko.donchev@gmail.com> > --- > fs/ntfs3/frecord.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c > index 3b42938a9d3b..d435446537ca 100644 > --- a/fs/ntfs3/frecord.c > +++ b/fs/ntfs3/frecord.c > @@ -2636,7 +2636,7 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, > goto out1; > } > > - pages_disk = kzalloc(npages_disk * sizeof(struct page *), GFP_NOFS); > + pages_disk = kcalloc(npages_disk, sizeof(struct page *), GFP_NOFS); `sizeof(*pages_disk)` is preferable over `sizeof(struct page *)` Thanks -- Gustavo > if (!pages_disk) { > err = -ENOMEM; > goto out2;
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 3b42938a9d3b..d435446537ca 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -2636,7 +2636,7 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, goto out1; } - pages_disk = kzalloc(npages_disk * sizeof(struct page *), GFP_NOFS); + pages_disk = kcalloc(npages_disk, sizeof(struct page *), GFP_NOFS); if (!pages_disk) { err = -ENOMEM; goto out2;