iio: core: Fix an error pointer vs NULL bug in devm_iio_device_alloc()

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: cf5724e915 ("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>
This commit is contained in:
Dan Carpenter 2021-05-15 12:56:39 +03:00 committed by Jonathan Cameron
parent 2a1c6a7743
commit 43fa739450

View file

@ -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;
}