Re: [PATCH v8 1/2] Driver for TI HDC20x0 humidity and temperature sensors

Jonathan Cameron
2020-06-14T11:31:13Z

On Thu, 11 Jun 2020 15:02:05 +0200
Eugene Zaikonnikov <ez@norphonic.com> wrote:

> Jonathan Cameron <Jonathan.Cameron@Huawei.com> writes:
>
> > On Mon, 18 May 2020 19:15:27 +0000
> > Eugene Zalkonnikov <ez@norphonic.com> wrote:
> >
> > Hi Eugene
> >
> >> HDC2010/2080 driver and sysfs documentation for its heater element.
> >>
> >
> > Would be nice to have a little more info on the device for anyone reading
> > the log after we commit this.
> >
> Ok I'll expand the description.
>
> > There is a potential double free in the remove path due to mix of
> > devm_iio_device_register and iio_device_unregister.
> >
> Right, overlooked this. Will changine the unregister to the managed
> version suffice?
Whilst that would work it would be a bad idea.

You need the unmanaged unregister before disabling auto measurement
(to remove the userspace interfaces before changing things so they won't
work).

So just use unmanaged iio_device_register in probe (and reorder to
put the unregister before the sensor stop). I think that will also
mirror the ordering in probe which should always be the case unless
there is a very good reason to do otherwise.

Jonathan

>
> > Also, the error paths in probe don't undo the various bits of setup
> > that it feels like they should. This might not matter in reality
> > but the code will be more obviously correct if it is fine to reset
> > the amm bit.
> >
> I'll add that.
>