Re: [PATCH] iio: add NULL pointer checks to iio device additional/removal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 3, 2022 at 2:04 PM Matt Ranostay <matt.ranostay@xxxxxxxxxxxx> wrote:
>
> Check if __iio_device_register and iio_device_unregister indio_dev
> parameter isn't a NULL pointer.

We refer to functions as func() in the text.

...

>  int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
>  {
> -       struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
> +       struct iio_dev_opaque *iio_dev_opaque;
>         struct fwnode_handle *fwnode;
>         int ret;
>
> -       if (!indio_dev->info)
> +       if (!indio_dev || !indio_dev->info)
>                 return -EINVAL;
>
> +       iio_dev_opaque = to_iio_dev_opaque(indio_dev);

Not sure we need this one. All callers check for indio_dev from the
allocator, otherwise I don't see a clean workflow when indio_dev is
NULL when calling register(). The other part is good.

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux