ntfs3.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/ntfs3: Use kmalloc_array for allocating multiple elements
@ 2022-08-19  5:51 Kenneth Lee
  2022-09-30 15:46 ` Konstantin Komarov
  0 siblings, 1 reply; 2+ messages in thread
From: Kenneth Lee @ 2022-08-19  5:51 UTC (permalink / raw)
  To: almaz.alexandrovich; +Cc: ntfs3, Kenneth Lee

Prefer using kmalloc_array(a, b) over kmalloc(a * b) as this
improves semantics since kmalloc is intended for allocating an
array of memory.

Signed-off-by: Kenneth Lee <klee33@uw.edu>
---
 fs/ntfs3/bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c
index 5d44ceac855b..1675c9a69788 100644
--- a/fs/ntfs3/bitmap.c
+++ b/fs/ntfs3/bitmap.c
@@ -1324,7 +1324,7 @@ int wnd_extend(struct wnd_bitmap *wnd, size_t new_bits)
 		new_last = wbits;
 
 	if (new_wnd != wnd->nwnd) {
-		new_free = kmalloc(new_wnd * sizeof(u16), GFP_NOFS);
+		new_free = kmalloc_array(new_wnd, sizeof(u16), GFP_NOFS);
 		if (!new_free)
 			return -ENOMEM;
 
-- 
2.31.1


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

* Re: [PATCH] fs/ntfs3: Use kmalloc_array for allocating multiple elements
  2022-08-19  5:51 [PATCH] fs/ntfs3: Use kmalloc_array for allocating multiple elements Kenneth Lee
@ 2022-09-30 15:46 ` Konstantin Komarov
  0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Komarov @ 2022-09-30 15:46 UTC (permalink / raw)
  To: Kenneth Lee; +Cc: ntfs3



On 8/19/22 08:51, Kenneth Lee wrote:
> Prefer using kmalloc_array(a, b) over kmalloc(a * b) as this
> improves semantics since kmalloc is intended for allocating an
> array of memory.
> 
> Signed-off-by: Kenneth Lee <klee33@uw.edu>
> ---
>   fs/ntfs3/bitmap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c
> index 5d44ceac855b..1675c9a69788 100644
> --- a/fs/ntfs3/bitmap.c
> +++ b/fs/ntfs3/bitmap.c
> @@ -1324,7 +1324,7 @@ int wnd_extend(struct wnd_bitmap *wnd, size_t new_bits)
>   		new_last = wbits;
>   
>   	if (new_wnd != wnd->nwnd) {
> -		new_free = kmalloc(new_wnd * sizeof(u16), GFP_NOFS);
> +		new_free = kmalloc_array(new_wnd, sizeof(u16), GFP_NOFS);
>   		if (!new_free)
>   			return -ENOMEM;
>   

Applied, thanks!

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

end of thread, other threads:[~2022-09-30 15:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-19  5:51 [PATCH] fs/ntfs3: Use kmalloc_array for allocating multiple elements Kenneth Lee
2022-09-30 15:46 ` Konstantin Komarov

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).