Re: [PATCH] iio: magnetometer: ak8975: fix potential kernel stack memory leak

From: Joshua Crofts

Date: Fri May 15 2026 - 06:17:01 EST


On Fri, 15 May 2026 at 11:51, Andy Shevchenko
<andriy.shevchenko@xxxxxxxxx> wrote:
>
> On Fri, May 15, 2026 at 11:00:17AM +0200, Joshua Crofts wrote:
> > On Thu, 14 May 2026 at 13:38, Joshua Crofts via B4 Relay
> > <devnull+joshua.crofts1.gmail.com@xxxxxxxxxx> wrote:
>
> ...
>
> > > - if (ret < 0)
> > > + if (ret != sizeof(fval)) {
> >
> > Hmm, Sashiko pointed out that I am comparing a signed integer with
> > an unsigned integer, which would result in type promotion and subsequent
> > mangling of any potential negative values... will fix in v2.
> >
> > https://sashiko.dev/#/patchset/20260514-magnetometer-kernel-mem-leak-v1-1-35b48d699faf%40gmail.com
>
> See my response. That how it should be in your v2.

Thanks. Checking the driver again I found 2 additional places where an
I2C read is going
into uninitialized memory that Sashiko missed.

--
Kind regards

CJD