md/raid0: fix uninitialized variable bug
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 14 Apr 2016 09:31:49 +0000 (12:31 +0300)
committerShaohua Li <shli@fb.com>
Thu, 14 Apr 2016 16:57:59 +0000 (09:57 -0700)
If this function fails the callers expect that *private_conf is set to
an ERR_PTR() but that isn't true for the first error path where we can't
allocate "conf".  It leads to some uninitialized variable bugs.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid0.c

index 2ea12c6bf65997895e26a89fe8977451ae438d97..f63dbb68e3a9c629ae0ee52301dccdbaf2379a33 100644 (file)
@@ -85,6 +85,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
        struct r0conf *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
        unsigned short blksize = 512;
 
+       *private_conf = ERR_PTR(-ENOMEM);
        if (!conf)
                return -ENOMEM;
        rdev_for_each(rdev1, mddev) {