All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] btrfs-progs: fix uninitialized copy of btrfs_fs_devices list
@ 2015-10-22  3:53 Anand Jain
  2015-10-23  9:48 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Anand Jain @ 2015-10-22  3:53 UTC (permalink / raw)
  To: linux-btrfs

Noticed that at print_one_uuid() some of the members of btrfs_fs_devices
contained some junk values. It took a while to dig this further, and found
that we make a local copy of the btrfs_fs_devices list at
search_umounted_fs_uuids() and wasn't initialized properly.

Fixed using using zalloc instead of malloc.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 cmds-filesystem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 3663734..4d3a9a4 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -685,7 +685,7 @@ static int search_umounted_fs_uuids(struct list_head *all_uuids,
 		if (is_seen_fsid(cur_fs->fsid))
 			continue;
 
-		fs_copy = malloc(sizeof(*fs_copy));
+		fs_copy = kzalloc(sizeof(*fs_copy), GFP_NOFS);
 		if (!fs_copy) {
 			ret = -ENOMEM;
 			goto out;
-- 
2.4.1


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

* Re: [PATCH 1/1] btrfs-progs: fix uninitialized copy of btrfs_fs_devices list
  2015-10-22  3:53 [PATCH 1/1] btrfs-progs: fix uninitialized copy of btrfs_fs_devices list Anand Jain
@ 2015-10-23  9:48 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2015-10-23  9:48 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs

On Thu, Oct 22, 2015 at 11:53:39AM +0800, Anand Jain wrote:
> Noticed that at print_one_uuid() some of the members of btrfs_fs_devices
> contained some junk values. It took a while to dig this further, and found
> that we make a local copy of the btrfs_fs_devices list at
> search_umounted_fs_uuids() and wasn't initialized properly.
> 
> Fixed using using zalloc instead of malloc.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  cmds-filesystem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cmds-filesystem.c b/cmds-filesystem.c
> index 3663734..4d3a9a4 100644
> --- a/cmds-filesystem.c
> +++ b/cmds-filesystem.c
> @@ -685,7 +685,7 @@ static int search_umounted_fs_uuids(struct list_head *all_uuids,
>  		if (is_seen_fsid(cur_fs->fsid))
>  			continue;
>  
> -		fs_copy = malloc(sizeof(*fs_copy));
> +		fs_copy = kzalloc(sizeof(*fs_copy), GFP_NOFS);

This is in purely userspace code, we can use malloc/calloc/free, I'll
update it and apply.

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

end of thread, other threads:[~2015-10-23  9:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-22  3:53 [PATCH 1/1] btrfs-progs: fix uninitialized copy of btrfs_fs_devices list Anand Jain
2015-10-23  9:48 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.