RE: [PATCH v2] iio: frequency: admv1013: fix NULL pointer dereference on str

From: Miclaus, Antoniu

Date: Wed Mar 04 2026 - 04:53:33 EST


> -----Original Message-----
> From: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
> Sent: Tuesday, March 3, 2026 3:55 PM
> To: Miclaus, Antoniu <Antoniu.Miclaus@xxxxxxxxxx>
> Cc: Lars-Peter Clausen <lars@xxxxxxxxxx>; Hennerich, Michael
> <Michael.Hennerich@xxxxxxxxxx>; Jonathan Cameron <jic23@xxxxxxxxxx>;
> David Lechner <dlechner@xxxxxxxxxxxx>; Sa, Nuno <Nuno.Sa@xxxxxxxxxx>;
> Andy Shevchenko <andy@xxxxxxxxxx>; linux-iio@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH v2] iio: frequency: admv1013: fix NULL pointer
> dereference on str
>
> [External]
>
> On Tue, Mar 03, 2026 at 12:01:31PM +0000, Miclaus, Antoniu wrote:
> > > -----Original Message-----
> > > From: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
> > > Sent: Tuesday, March 3, 2026 1:34 PM
> > > On Tue, Mar 03, 2026 at 11:52:28AM +0200, Antoniu Miclaus wrote:
>
> ...
>
> > > > +static const char * const admv1013_quad_se_modes[] = { "diff", "se-
> pos",
> > > "se-neg" };
> > >
> > > Taking into account the indices are not sequential, this may require another
> > > enumerator.
> > >
> > > Ideally you need to list all possible modes and choose only supported by
> > > assigning an empty string to unsupported ones.
> > >
> > > I haven't checked datasheet to understand why only 6, 9, 12 are in use.
> > > Maybe they can be simply 1, 2, 3 with a formula like 3 + x * 3 ? Dunno.
> > >
> >
> > static const char * const admv1013_input_modes[] = {
> > [ADMV1013_IQ_MODE] = "iq",
> > [ADMV1013_IF_MODE] = "if",
> > };
> >
> > static const char * const admv1013_quad_se_modes[] = {
> > [ADMV1013_QUAD_SE_DIFF] = "diff",
> > [ADMV1013_QUAD_SE_POS] = "se-pos",
> > [ADMV1013_QUAD_SE_NEG] = "se-neg",
> > };
> >
> > static const unsigned int admv1013_quad_se_regvals[] = {
> > [ADMV1013_QUAD_SE_DIFF] = ADMV1013_SE_MODE_DIFF,
> > [ADMV1013_QUAD_SE_POS] = ADMV1013_SE_MODE_POS,
> > [ADMV1013_QUAD_SE_NEG] = ADMV1013_SE_MODE_NEG,
> > };
> >
> > Does this make sense?
>
> Yes, if there is an explanation why we have 6,9,12 to begin with. Can
> somebody
> study the available datasheets and come up with the explanations?

There are the values accepted by the QUAD_SE_MODE bitfield.

https://www.analog.com/media/en/technical-documentation/data-sheets/admv1013.pdf
Page 37 of 39, Table 15.

>
> --
> With Best Regards,
> Andy Shevchenko
>