Re: [PATCH v4] iio: frequency: admv1013: fix NULL pointer dereference on str
From: Andy Shevchenko
Date: Thu Mar 05 2026 - 04:54:44 EST
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>
> I think it makes a bit more sense to be here where we handle all the initial
> register configurations.
Agree.
--
With Best Regards,
Andy Shevchenko