|
@@ -567,7 +567,10 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
|
|
struct inode *inode;
|
|
|
struct device *dev;
|
|
|
struct cdev *cdev;
|
|
|
- int rc = 0, i;
|
|
|
+ int rc, i;
|
|
|
+
|
|
|
+ if (!count)
|
|
|
+ return ERR_PTR(-EINVAL);
|
|
|
|
|
|
dev_dax = kzalloc(sizeof(*dev_dax) + sizeof(*res) * count, GFP_KERNEL);
|
|
|
if (!dev_dax)
|
|
@@ -598,8 +601,10 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
|
|
* device outside of mmap of the resulting character device.
|
|
|
*/
|
|
|
dax_dev = alloc_dax(dev_dax, NULL, NULL);
|
|
|
- if (!dax_dev)
|
|
|
+ if (!dax_dev) {
|
|
|
+ rc = -ENOMEM;
|
|
|
goto err_dax;
|
|
|
+ }
|
|
|
|
|
|
/* from here on we're committed to teardown via dax_dev_release() */
|
|
|
dev = &dev_dax->dev;
|