Re: [PATCH v4] iio: frequency: admv1013: fix NULL pointer dereference on str

From: Jonathan Cameron

Date: Sat Mar 07 2026 - 07:12:14 EST


On Thu, 5 Mar 2026 11:51:51 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:

> On Thu, Mar 05, 2026 at 09:44:35AM +0000, Miclaus, Antoniu wrote:
> > > -----Original Message-----
> > > From: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>
> > > Sent: Thursday, March 5, 2026 11:36 AM
> > > On Thu, Mar 5, 2026 at 11:15 AM Antoniu Miclaus
> > > <antoniu.miclaus@xxxxxxxxxx> wrote:
>
> ...
>
> > > > static int admv1013_init(struct admv1013_state *st, int vcm_uv)
> > >
> > > > - data = FIELD_PREP(ADMV1013_QUAD_SE_MODE_MSK, st-
> > > >quad_se_mode);
> > > > + switch (st->quad_se_mode) {
> > > > + case ADMV1013_SE_MODE_POS:
> > > > + data = 6;
> > > > + break;
> > > > + case ADMV1013_SE_MODE_NEG:
> > > > + data = 9;
> > > > + break;
> > > > + case ADMV1013_SE_MODE_DIFF:
> > > > + data = 12;
> > > > + break;
> > > > + default:
> > > > + return -EINVAL;
> > > > + }
> > >
> > > Oh, I haven't realised that it can be done like this. I have in mind
> > > just to have a switch in the probe, so we don't need to do that again
> > > and again. Otherwise looks good to me.
> >
> > Hmm, the _init() function is called only in the probe.
>
> Ah, missed that. Then we are good.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>

Unfortunately we have some cleanup quite a way back in my tree for this cycle
and I'm not keen to rebase to drop it all. So we'll need to manually back port
this after it merges in the next merge window.

If we need to do it more urgently I'll need a patch against togreg-fixes. Let me know
if you think this is necessary. For now I've applied it on the testing branch.

Jonathan

>
> > I think it makes a bit more sense to be here where we handle all the initial
> > register configurations.
>
> Agree.
>