diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2016-10-12 09:34:29 +0300 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2016-10-19 20:35:51 +0300 |
commit | 75d29713b792da4782cadfaa87e802183440694e (patch) | |
tree | 3d279ed95896399f5b220ac0c554d632432de89a /drivers | |
parent | 1001354ca34179f3db924eb66672442a173147dc (diff) | |
download | linux-75d29713b792da4782cadfaa87e802183440694e.tar.xz |
libnvdimm, namespace: potential NULL deref on allocation error
If the kcalloc() fails then "devs" can be NULL and we dereference it
checking "devs[i]".
Fixes: 1b40e09a1232 ('libnvdimm: blk labels and namespace instantiation')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/nvdimm/namespace_devs.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index 3509cff68ef9..abe5c6bc756c 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -2176,12 +2176,14 @@ static struct device **scan_labels(struct nd_region *nd_region) return devs; err: - for (i = 0; devs[i]; i++) - if (is_nd_blk(&nd_region->dev)) - namespace_blk_release(devs[i]); - else - namespace_pmem_release(devs[i]); - kfree(devs); + if (devs) { + for (i = 0; devs[i]; i++) + if (is_nd_blk(&nd_region->dev)) + namespace_blk_release(devs[i]); + else + namespace_pmem_release(devs[i]); + kfree(devs); + } return NULL; } |