linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 25/27] kernel: power: use kzalloc rather than kmalloc followed with memset
@ 2019-06-28  2:50 Fuqian Huang
  2019-06-28 10:16 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Fuqian Huang @ 2019-06-28  2:50 UTC (permalink / raw)
  Cc: Fuqian Huang, Rafael J. Wysocki, Len Brown, Pavel Machek,
	linux-pm, linux-kernel

Use zeroing allocator instead of using allocator
followed with memset with 0

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
---
 kernel/power/swap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index e1912ad13bdc..ca0fcb5ced71 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -974,12 +974,11 @@ static int get_swap_reader(struct swap_map_handle *handle,
 	last = handle->maps = NULL;
 	offset = swsusp_header->image;
 	while (offset) {
-		tmp = kmalloc(sizeof(*handle->maps), GFP_KERNEL);
+		tmp = kzalloc(sizeof(*handle->maps), GFP_KERNEL);
 		if (!tmp) {
 			release_swap_reader(handle);
 			return -ENOMEM;
 		}
-		memset(tmp, 0, sizeof(*tmp));
 		if (!handle->maps)
 			handle->maps = tmp;
 		if (last)
-- 
2.11.0


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

* Re: [PATCH v2 25/27] kernel: power: use kzalloc rather than kmalloc followed with memset
  2019-06-28  2:50 [PATCH v2 25/27] kernel: power: use kzalloc rather than kmalloc followed with memset Fuqian Huang
@ 2019-06-28 10:16 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2019-06-28 10:16 UTC (permalink / raw)
  To: Fuqian Huang; +Cc: Len Brown, Pavel Machek, linux-pm, linux-kernel

On Friday, June 28, 2019 4:50:35 AM CEST Fuqian Huang wrote:
> Use zeroing allocator instead of using allocator
> followed with memset with 0
> 
> Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
> ---
>  kernel/power/swap.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index e1912ad13bdc..ca0fcb5ced71 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -974,12 +974,11 @@ static int get_swap_reader(struct swap_map_handle *handle,
>  	last = handle->maps = NULL;
>  	offset = swsusp_header->image;
>  	while (offset) {
> -		tmp = kmalloc(sizeof(*handle->maps), GFP_KERNEL);
> +		tmp = kzalloc(sizeof(*handle->maps), GFP_KERNEL);
>  		if (!tmp) {
>  			release_swap_reader(handle);
>  			return -ENOMEM;
>  		}
> -		memset(tmp, 0, sizeof(*tmp));
>  		if (!handle->maps)
>  			handle->maps = tmp;
>  		if (last)
> 

Queued up for 5.3 with minor subject changes.  Thanks!




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

end of thread, other threads:[~2019-06-28 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-28  2:50 [PATCH v2 25/27] kernel: power: use kzalloc rather than kmalloc followed with memset Fuqian Huang
2019-06-28 10:16 ` Rafael J. Wysocki

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