From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Antoniu Miclaus <antoniu.miclaus@analog.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: frequency: admv1013: fix NULL pointer dereference on str
Date: Tue, 3 Mar 2026 13:33:42 +0200 [thread overview]
Message-ID: <aabHFq2PZssgpK2G@ashevche-desk.local> (raw)
In-Reply-To: <20260303095228.7494-1-antoniu.miclaus@analog.com>
On Tue, Mar 03, 2026 at 11:52:28AM +0200, Antoniu Miclaus wrote:
> When device_property_read_string() fails, str is left uninitialized
> but the code falls through to strcmp(str, ...), dereferencing a garbage
> pointer. Replace manual read/strcmp with
> device_property_match_property_string() which reads the property as a
> single string value and matches it against an array of known valid
> strings, handling the missing property case internally.
...
> +static const char * const admv1013_input_modes[] = { "iq", "if" };
This array has to be indexed.
static const char * const admv1013_input_modes[] = {
[ADMV1013_IQ_MODE] = "iq",
[ADMV1013_IF_MODE] = "if",
};
...
> +static const char * const admv1013_quad_se_modes[] = { "diff", "se-pos", "se-neg" };
Also this one.
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.
...
> + switch (ret) {
> + case 1:
> st->quad_se_mode = ADMV1013_SE_MODE_POS;
> - else if (!strcmp(str, "se-neg"))
> + break;
> + case 2:
> st->quad_se_mode = ADMV1013_SE_MODE_NEG;
> + break;
This (the default) should take
case 0:
as well
> + default:
> + st->quad_se_mode = ADMV1013_SE_MODE_DIFF;
> + break;
> + }
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-03-03 11:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 9:52 [PATCH v2] iio: frequency: admv1013: fix NULL pointer dereference on str Antoniu Miclaus
2026-03-03 11:33 ` Andy Shevchenko [this message]
2026-03-03 12:01 ` Miclaus, Antoniu
2026-03-03 13:54 ` Andy Shevchenko
2026-03-04 9:52 ` Miclaus, Antoniu
2026-03-04 14:06 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aabHFq2PZssgpK2G@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=antoniu.miclaus@analog.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox