diff mbox

[ndctl,6/7] ndctl: fix uninitialized variable in add_dimm()

Message ID 146161382084.21779.5170696006378099616.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit 835295aa56f6
Headers show

Commit Message

Dan Williams April 25, 2016, 7:50 p.m. UTC
Static analysis notes 'rc' might not be set if we fail to allocate
'dimm'.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 lib/libndctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/lib/libndctl.c b/lib/libndctl.c
index 5c2894d6b82e..58b7fa9d6666 100644
--- a/lib/libndctl.c
+++ b/lib/libndctl.c
@@ -1184,9 +1184,9 @@  static struct kmod_module *to_module(struct ndctl_ctx *ctx, const char *alias);
 
 static int add_dimm(void *parent, int id, const char *dimm_base)
 {
-	int rc, formats, i;
 	struct ndctl_dimm *dimm;
 	char buf[SYSFS_ATTR_SIZE];
+	int rc = -ENOMEM, formats, i;
 	struct ndctl_bus *bus = parent;
 	struct ndctl_ctx *ctx = bus->ctx;
 	char *path = calloc(1, strlen(dimm_base) + 100);