Btrfs-progs: subvol_uuid_search: Return error code on memory allocation failure
PATCH 1/1 Btrfs-progs: subvol_uuid_search: Return error code on memory allocation failure
From: Prasanth K S R <[email protected]>
This commit fixes coverity defect CID 1328695.
Signed-off-by Prasanth K S R <[email protected]>
--- send-utils.c | 5 +++++ 1 file changed, 5 insertions(+)
send-utils.c +5 -0
@@ -486,6 +486,11 @@ struct subvol_info *subvol_uuid_search(struct subvol_uuid_search *s, info->path =strdup (path); }else { info->path =malloc (PATH_MAX ); +if (!info->path) { +fprintf (stderr,"Memory allocation failed\n" ); + ret = -ENOMEM ; + goto out; + } ret =btrfs_subvolid_resolve (s->mnt_fd, info->path,PATH_MAX , root_id); }
Signature · 1 line
2.7.4
Quoted 14 lines · Prasanth K S R
From: Prasanth K S R <[email protected]>
This commit fixes coverity defect CID 1328695.
Signed-off-by Prasanth K S R <[email protected]>--- send-utils.c | 5 +++++ 1 file changed, 5 insertions(+)send-utils.c +0
-0
send-utils.c struct subvol_info *subvol_uuid_search(struct subvol_uuid_search *s, · line 490
Quoted 5 lines
send-utils.c +2
-0@@ -486,6 +486,11 @@ struct subvol_info *subvol_uuid_search(struct subvol_uuid_search *s, info->path =strdup (path); }else { info->path =malloc (PATH_MAX ); +if (!info->path) { +fprintf (stderr,"Memory allocation failed\n" );
Please use the error() helper (does not need \n terminated string).
Also, would be grat to convert subvol_uuid_search to return ERR_PTR style value (which means to conver all callers). Now we don't see why exactly it fails and interpret it as nonexistence of the uuid.