From d827cfbde6daaebc40f76611621ad781634d5966 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Mon, 27 Mar 2017 09:55:00 -0700 Subject: [PATCH] blob: Handle allocation failures in set xattr Change-Id: Ida9361066e8b3117d1022379d75e290b11f86b52 Signed-off-by: Ben Walker --- lib/blob/blobstore.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index bc43883a2..833f7c415 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -2221,11 +2221,10 @@ spdk_blob_md_set_xattr(struct spdk_blob *blob, const char *name, const void *val } } - /* - * This is probably all going to rewritten, so do not bother checking for failed - * allocations for now. - */ xattr = calloc(1, sizeof(*xattr)); + if (!xattr) { + return -1; + } xattr->name = strdup(name); xattr->value_len = value_len; xattr->value = malloc(value_len);