diff mbox

[1/3] Btrfs-progs: subvol_uuid_search: Return error on memory allocation failure

Message ID 20161210134744.10825-1-kosigiprasanth@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

Prasanth KSR Dec. 10, 2016, 1:47 p.m. UTC
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 | 4 ++++
 1 file changed, 4 insertions(+)

Comments

David Sterba Dec. 12, 2016, 4:35 p.m. UTC | #1
On Sat, Dec 10, 2016 at 07:17:42PM +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>

Thanks, 1-3 applied.

JFYI, I've realized that subvol_uuid_search is part of the public API so
changing the return value would break the existing users (I know that
snapper uses this function), as it now returns just a pointer or NULL.
I'll fix that, a new function and library version bump would be needed.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/send-utils.c b/send-utils.c
index a85fa08..5026882 100644
--- a/send-utils.c
+++ b/send-utils.c
@@ -486,6 +486,10 @@  struct subvol_info *subvol_uuid_search(struct subvol_uuid_search *s,
 		info->path = strdup(path);
 	} else {
 		info->path = malloc(PATH_MAX);
+		if (!info->path) {
+			ret = -ENOMEM;
+			goto out;
+		}
 		ret = btrfs_subvolid_resolve(s->mnt_fd, info->path,
 					     PATH_MAX, root_id);
 	}