]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: buffer: Return error if no callback is given
authorNuno Sá <nuno.sa@analog.com>
Sat, 21 Nov 2020 16:14:57 +0000 (17:14 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 3 Dec 2020 19:32:40 +0000 (19:32 +0000)
Return error in case no callback is provided to
`iio_channel_get_all_cb()`. There's no point in setting up a buffer-cb
if no callback is provided.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Olivier Moysan <olivier.moysan@st.com>
Link: https://lore.kernel.org/r/20201121161457.957-3-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/buffer/industrialio-buffer-cb.c

index 47c96f7f4976279abed928635245832d0b5b620f..4c12b7a94af59ae9c3ac01b17b8704f85ec22e87 100644 (file)
@@ -54,6 +54,11 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
        struct iio_cb_buffer *cb_buff;
        struct iio_channel *chan;
 
+       if (!cb) {
+               dev_err(dev, "Invalid arguments: A callback must be provided!\n");
+               return ERR_PTR(-EINVAL);
+       }
+
        cb_buff = kzalloc(sizeof(*cb_buff), GFP_KERNEL);
        if (cb_buff == NULL)
                return ERR_PTR(-ENOMEM);