Re: [PATCH v2 1/5] gpio: sysfs: use cleanup guards for gpiod_data::mutex
From: Bartosz Golaszewski
Date: Fri Oct 25 2024 - 12:13:03 EST
On Fri, Oct 25, 2024 at 5:34 PM Kent Gibson <warthog618@xxxxxxxxx> wrote:
>
> >
> > Yeah, I don't know why it was done. Typically you want to sanitize the
> > input before anything else and this is what's done almost everywhere
> > else. I'd keep it like that.
>
> Not knowing why it was done was precisely the reason I thought it
> should be left as is. The fact that the checks are performed in the
> other order elsewhere makes me think this one was done intentionally.
> Conceivably it could be used by userspace to test if a line is output when
> the direction is fixed (so /sys/class/gpio/gpioN/direction does not exist).
> So write a non-integer to the value and see if it returns -EPERM rather
> than -EINVAL.
>
> Admittedly I'm speculating, but I can't rule it out, so I wouldn't
> change the behaviour just because it is more aesthetically pleasing.
> And if you insist on tidying the behaviour then it should be in a separate
> patch rather than piggy-backing onto the guard change.
>
> Anyway, that is my 2c.
>
Ok, I'll restore the order in v3.
Bartosz