From: Alexandru Ardelean <ardeleanalex@gmail.com>
To: "Nuno Sá" <nuno.sa@analog.com>
Cc: linux-iio <linux-iio@vger.kernel.org>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Drew Fustini <drew@pdp7.com>
Subject: Re: [PATCH 2/2] iio: ltc2983: fail probe if no channels are given
Date: Fri, 20 Aug 2021 11:22:46 +0300 [thread overview]
Message-ID: <CA+U=DsqgbFUWcAF=S6bz_mOqN+MHjprQxMXZajkeNKAdGquLSQ@mail.gmail.com> (raw)
In-Reply-To: <20210820065535.6994-2-nuno.sa@analog.com>
On Fri, Aug 20, 2021 at 9:53 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> If there are no channels defined in the devicetree, there's no point in
> probing the device. We were actually requesting a zero sized 'kmalloc'
> array but since we were not touching the ZERO_SIZE_PTR afterwards,
> nothing bad was actually happening. Hence this is not really a fix but
> rather an improvement.
>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
> drivers/iio/temperature/ltc2983.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
> index 37903e9fb90f..7dd2f1dd3685 100644
> --- a/drivers/iio/temperature/ltc2983.c
> +++ b/drivers/iio/temperature/ltc2983.c
> @@ -1275,6 +1275,11 @@ static int ltc2983_parse_dt(struct ltc2983_data *st)
> &st->filter_notch_freq);
>
> st->num_channels = of_get_available_child_count(dev->of_node);
> + if (!st->num_channels) {
> + dev_err(&st->spi->dev, "At least one channel must be given!");
> + return -EINVAL;
> + }
> +
> st->sensors = devm_kcalloc(dev, st->num_channels, sizeof(*st->sensors),
> GFP_KERNEL);
> if (!st->sensors)
> --
> 2.33.0
>
next prev parent reply other threads:[~2021-08-20 8:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-20 6:55 [PATCH 1/2] iio: ltc2983: add support for optional reset gpio Nuno Sá
2021-08-20 6:55 ` [PATCH 2/2] iio: ltc2983: fail probe if no channels are given Nuno Sá
2021-08-20 8:22 ` Alexandru Ardelean [this message]
2021-08-20 8:21 ` [PATCH 1/2] iio: ltc2983: add support for optional reset gpio Alexandru Ardelean
2021-08-20 9:29 ` Sa, Nuno
2021-08-20 18:58 ` Alexandru Ardelean
2021-08-23 7:04 ` Sa, Nuno
2021-08-25 8:24 ` Sa, Nuno
2021-08-23 11:14 ` Andy Shevchenko
2021-08-23 12:51 ` Nuno Sá
2021-08-23 14:27 ` Andy Shevchenko
2021-08-23 14:51 ` Nuno Sá
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='CA+U=DsqgbFUWcAF=S6bz_mOqN+MHjprQxMXZajkeNKAdGquLSQ@mail.gmail.com' \
--to=ardeleanalex@gmail.com \
--cc=drew@pdp7.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@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;
as well as URLs for NNTP newsgroup(s).