From 43fa739450492a0b870802d471de923184870a4c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 15 May 2021 12:56:39 +0300 Subject: [PATCH] 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: cf5724e91515 ("iio: core: simplify some devm functions") Signed-off-by: Dan Carpenter Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/YJ+a1yaMu2QNATgt@mwanda Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index bfa20a346f71..75e92bac78f3 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -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; } -- 2.11.0