* [PATCH] Btrfs-progs: subvol_uuid_search: Return error code on memory allocation failure
@ 2016-10-05 13:03 Prasanth K S R
2016-10-06 15:45 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Prasanth K S R @ 2016-10-05 13:03 UTC (permalink / raw)
To: linux-btrfs; +Cc: Prasanth K S R, dsterba
From: Prasanth K S R <prasanth.ksr@dell.com>
This commit fixes coverity defect CID 1328695.
Signed-off-by: Prasanth K S R <prasanth.ksr@dell.com>
---
send-utils.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/send-utils.c b/send-utils.c
index a85fa08..6f80b6f 100644
--- a/send-utils.c
+++ b/send-utils.c
@@ -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);
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Btrfs-progs: subvol_uuid_search: Return error code on memory allocation failure
2016-10-05 13:03 [PATCH] Btrfs-progs: subvol_uuid_search: Return error code on memory allocation failure Prasanth K S R
@ 2016-10-06 15:45 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2016-10-06 15:45 UTC (permalink / raw)
To: Prasanth K S R; +Cc: linux-btrfs, Prasanth K S R, dsterba
On Wed, Oct 05, 2016 at 06:33:12PM +0530, Prasanth K S R wrote:
> From: Prasanth K S R <prasanth.ksr@dell.com>
>
> This commit fixes coverity defect CID 1328695.
>
> Signed-off-by: Prasanth K S R <prasanth.ksr@dell.com>
> ---
> send-utils.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/send-utils.c b/send-utils.c
> index a85fa08..6f80b6f 100644
> --- a/send-utils.c
> +++ b/send-utils.c
> @@ -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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-06 15:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-05 13:03 [PATCH] Btrfs-progs: subvol_uuid_search: Return error code on memory allocation failure Prasanth K S R
2016-10-06 15:45 ` David Sterba
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).