All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: linux-iio@vger.kernel.org
Subject: Re: [bug report] iio: light: isl29018: Replace a variant of iio_get_acpi_device_name_and_data()
Date: Wed, 30 Oct 2024 16:50:13 +0200	[thread overview]
Message-ID: <ZyJHpaWms8Fe2x94@smile.fi.intel.com> (raw)
In-Reply-To: <54fac4a7-b601-40ce-8c00-d94807f5e214@stanley.mountain>

On Wed, Oct 30, 2024 at 12:53:57PM +0300, Dan Carpenter wrote:
> Hello Andy Shevchenko,
> 
> Commit 14686836fb69 ("iio: light: isl29018: Replace a variant of
> iio_get_acpi_device_name_and_data()") from Oct 24, 2024 (linux-next),
> leads to the following Smatch static checker warning:
> 
>     drivers/iio/light/isl29018.c:724 isl29018_probe() error: uninitialized symbol 'ddata'.
>     drivers/iio/light/ltr501.c:1514 ltr501_probe() error: uninitialized symbol 'ddata'.
> 
> drivers/iio/light/isl29018.c
>     701 static int isl29018_probe(struct i2c_client *client)
>     702 {
>     703         const struct i2c_device_id *id = i2c_client_get_device_id(client);
>     704         struct isl29018_chip *chip;
>     705         struct iio_dev *indio_dev;
>     706         const void *ddata;
>     707         const char *name;
>     708         int dev_id;
>     709         int err;
>     710 
>     711         indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
>     712         if (!indio_dev)
>     713                 return -ENOMEM;
>     714 
>     715         chip = iio_priv(indio_dev);
>     716 
>     717         i2c_set_clientdata(client, indio_dev);
>     718 
>     719         if (id) {
>     720                 name = id->name;
>     721                 dev_id = id->driver_data;
>     722         } else {
>     723                 name = iio_get_acpi_device_name_and_data(&client->dev, &ddata);
> --> 724                 dev_id = (intptr_t)ddata;
> 
> How do we know that iio_get_acpi_device_name_and_data() will succeed?

Ideally we need to file &ddata with NULL in such case, but it will be
equal to 0, so it only works with the chip_info in place.

Let me look into this once more, thanks for the good catch!

>     725         }
>     726 
>     727         mutex_init(&chip->lock);
>     728 
>     729         chip->type = dev_id;

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-10-30 14:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-30  9:53 [bug report] iio: light: isl29018: Replace a variant of iio_get_acpi_device_name_and_data() Dan Carpenter
2024-10-30 14:50 ` Andy Shevchenko [this message]
2024-10-31  8:21   ` Andy Shevchenko
2024-10-31  8:39     ` Dan Carpenter
2024-11-01 14:10 ` Markus Elfring

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=ZyJHpaWms8Fe2x94@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.