kernel-hardening.lists.openwall.com archive mirror
 help / color / mirror / Atom feed
* [PATCH] dm: change kzalloc to kcalloc
@ 2024-12-24 22:13 Ethan Carter Edwards
  2024-12-24 22:42 ` Gustavo A. R. Silva
  0 siblings, 1 reply; 2+ messages in thread
From: Ethan Carter Edwards @ 2024-12-24 22:13 UTC (permalink / raw)
  To: agk@redhat.com
  Cc: snitzer@kernel.org, dm-devel@lists.linux.dev,
	linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com,
	linux-hardening@vger.kernel.org, mpatocka@redhat.com

Use 2-factor multiplication argument form kcalloc() instead
of instead of the deprecated kzalloc() [1].

[1] https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
Link: https://github.com/KSPP/linux/issues/162

Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
 drivers/md/dm-ps-io-affinity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-ps-io-affinity.c b/drivers/md/dm-ps-io-affinity.c
index 461ee6b2044d..716807e511ee 100644
--- a/drivers/md/dm-ps-io-affinity.c
+++ b/drivers/md/dm-ps-io-affinity.c
@@ -116,7 +116,7 @@ static int ioa_create(struct path_selector *ps, unsigned int argc, char **argv)
 	if (!s)
 		return -ENOMEM;
 
-	s->path_map = kzalloc(nr_cpu_ids * sizeof(struct path_info *),
+	s->path_map = kcalloc(nr_cpu_ids, sizeof(struct path_info *),
 			     GFP_KERNEL);
 	if (!s->path_map)
 		goto free_selector;
-- 
2.47.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dm: change kzalloc to kcalloc
  2024-12-24 22:13 [PATCH] dm: change kzalloc to kcalloc Ethan Carter Edwards
@ 2024-12-24 22:42 ` Gustavo A. R. Silva
  0 siblings, 0 replies; 2+ messages in thread
From: Gustavo A. R. Silva @ 2024-12-24 22:42 UTC (permalink / raw)
  To: Ethan Carter Edwards, agk@redhat.com
  Cc: snitzer@kernel.org, dm-devel@lists.linux.dev,
	linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com,
	linux-hardening@vger.kernel.org, mpatocka@redhat.com



On 24/12/24 16:13, Ethan Carter Edwards wrote:
> Use 2-factor multiplication argument form kcalloc() instead
> of instead of the deprecated kzalloc() [1].

Thanks for the patch - Just note that kzalloc() is by no means
deprecated.

> 
> [1] https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
> Link: https://github.com/KSPP/linux/issues/162
> 
> Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

-Gustavo

> ---
>   drivers/md/dm-ps-io-affinity.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/dm-ps-io-affinity.c b/drivers/md/dm-ps-io-affinity.c
> index 461ee6b2044d..716807e511ee 100644
> --- a/drivers/md/dm-ps-io-affinity.c
> +++ b/drivers/md/dm-ps-io-affinity.c
> @@ -116,7 +116,7 @@ static int ioa_create(struct path_selector *ps, unsigned int argc, char **argv)
>   	if (!s)
>   		return -ENOMEM;
>   
> -	s->path_map = kzalloc(nr_cpu_ids * sizeof(struct path_info *),
> +	s->path_map = kcalloc(nr_cpu_ids, sizeof(struct path_info *),
>   			     GFP_KERNEL);
>   	if (!s->path_map)
>   		goto free_selector;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-25  3:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-24 22:13 [PATCH] dm: change kzalloc to kcalloc Ethan Carter Edwards
2024-12-24 22:42 ` Gustavo A. R. Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).