Skip to content

Commit

Permalink
iio: core: Fix an error pointer vs NULL bug in devm_iio_device_alloc()
Browse files Browse the repository at this point in the history
The devm_iio_device_alloc() function is supposed to return NULL and not
error pointers.  Returning an error pointer will lead to a crash in the
callers.

Fixes: cf5724e ("iio: core: simplify some devm functions")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/YJ+a1yaMu2QNATgt@mwanda
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
Dan Carpenter authored and Jonathan Cameron committed May 17, 2021
1 parent 2a1c6a7 commit 43fa739
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iio/industrialio-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ struct iio_dev *devm_iio_device_alloc(struct device *parent, int sizeof_priv)
ret = devm_add_action_or_reset(parent, devm_iio_device_release,
iio_dev);
if (ret)
return ERR_PTR(ret);
return NULL;

return iio_dev;
}
Expand Down

0 comments on commit 43fa739

Please sign in to comment.