* [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data()
@ 2024-11-01 13:16 Andy Shevchenko
2024-11-01 13:16 ` [PATCH v3 1/4] iio: light: isl29018: Assign NULL to ddata in isl29018_probe() Andy Shevchenko
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-11-01 13:16 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko, linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen
Dan reported that ddata might be used uninitialised in some cases.
Let's initialise it to NULL (patches 1 - 3). With that, update one driver
to drop an unneeded anymore check (included in patch 3).
While at it, one more cleanup to kxcjk-1013 (patch 4) is added.
Jonathan, dunno if you want to rebase at this stage (probably not),
but if you do, feel free to fold the patches 1-3 to the initial code.
In v3:
- made Subject more specific for patches 1-3 (Markus)
In v2:
- rewritten patches 1-3 to do the job on the caller side (Jonathan)
Andy Shevchenko (4):
iio: light: isl29018: Assign NULL to ddata in isl29018_probe()
iio: light: ltr501: Assign NULL to ddata in ltr501_probe()
iio: accel: kxcjk-1013: Assign NULL to ddata in kxcjk1013_probe()
iio: accel: kxcjk-1013: Deduplicate ODR startup time array
drivers/iio/accel/kxcjk-1013.c | 30 ++++++------------------------
drivers/iio/light/isl29018.c | 2 +-
drivers/iio/light/ltr501.c | 2 +-
3 files changed, 8 insertions(+), 26 deletions(-)
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/4] iio: light: isl29018: Assign NULL to ddata in isl29018_probe()
2024-11-01 13:16 [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data() Andy Shevchenko
@ 2024-11-01 13:16 ` Andy Shevchenko
2024-11-01 13:16 ` [PATCH v3 2/4] iio: light: ltr501: Assign NULL to ddata in ltr501_probe() Andy Shevchenko
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-11-01 13:16 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko, linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen, Dan Carpenter
When iio_get_acpi_device_name_and_data() fails, the ddata may be left
uninitialised. Initialise it to NULL.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/54fac4a7-b601-40ce-8c00-d94807f5e214@stanley.mountain
Fixes: 14686836fb69 ("iio: light: isl29018: Replace a variant of iio_get_acpi_device_name_and_data()")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/light/isl29018.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
index cbe34026bda6..201eae1c4589 100644
--- a/drivers/iio/light/isl29018.c
+++ b/drivers/iio/light/isl29018.c
@@ -703,7 +703,7 @@ static int isl29018_probe(struct i2c_client *client)
const struct i2c_device_id *id = i2c_client_get_device_id(client);
struct isl29018_chip *chip;
struct iio_dev *indio_dev;
- const void *ddata;
+ const void *ddata = NULL;
const char *name;
int dev_id;
int err;
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/4] iio: light: ltr501: Assign NULL to ddata in ltr501_probe()
2024-11-01 13:16 [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data() Andy Shevchenko
2024-11-01 13:16 ` [PATCH v3 1/4] iio: light: isl29018: Assign NULL to ddata in isl29018_probe() Andy Shevchenko
@ 2024-11-01 13:16 ` Andy Shevchenko
2024-11-01 13:16 ` [PATCH v3 3/4] iio: accel: kxcjk-1013: Assign NULL to ddata in kxcjk1013_probe() Andy Shevchenko
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-11-01 13:16 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko, linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen, Dan Carpenter
When iio_get_acpi_device_name_and_data() fails, the ddata may be left
uninitialised. Initialise it to NULL.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/54fac4a7-b601-40ce-8c00-d94807f5e214@stanley.mountain
Fixes: 61da460b813d ("iio: light: ltr501: Replace a variant of iio_get_acpi_device_name_and_data()")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/light/ltr501.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 7228611d4c59..616dc6921702 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -1424,8 +1424,8 @@ static int ltr501_probe(struct i2c_client *client)
struct ltr501_data *data;
struct iio_dev *indio_dev;
struct regmap *regmap;
+ const void *ddata = NULL;
int partid, chip_idx;
- const void *ddata;
const char *name;
int ret;
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/4] iio: accel: kxcjk-1013: Assign NULL to ddata in kxcjk1013_probe()
2024-11-01 13:16 [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data() Andy Shevchenko
2024-11-01 13:16 ` [PATCH v3 1/4] iio: light: isl29018: Assign NULL to ddata in isl29018_probe() Andy Shevchenko
2024-11-01 13:16 ` [PATCH v3 2/4] iio: light: ltr501: Assign NULL to ddata in ltr501_probe() Andy Shevchenko
@ 2024-11-01 13:16 ` Andy Shevchenko
2024-11-01 13:16 ` [PATCH v3 4/4] iio: accel: kxcjk-1013: Deduplicate ODR startup time array Andy Shevchenko
2024-11-01 14:59 ` [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data() Jonathan Cameron
4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-11-01 13:16 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko, linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen
When iio_get_acpi_device_name_and_data() fails, the ddata may be left
uninitialised. Initialise it to NULL and drop unneeded NULL check
in kxcjk1013_probe().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/accel/kxcjk-1013.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index 28ed0e09d099..753ec2f71a9a 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -1462,7 +1462,7 @@ static int kxcjk1013_probe(struct i2c_client *client)
struct kxcjk1013_data *data;
struct iio_dev *indio_dev;
struct kxcjk_1013_platform_data *pdata;
- const void *ddata;
+ const void *ddata = NULL;
const char *name;
int ret;
@@ -1507,8 +1507,7 @@ static int kxcjk1013_probe(struct i2c_client *client)
data->info = (const struct kx_chipset_info *)(id->driver_data);
} else {
name = iio_get_acpi_device_name_and_data(&client->dev, &ddata);
- if (name)
- data->info = ddata;
+ data->info = ddata;
if (data->info == &kxcj91008_kiox010a_info)
indio_dev->label = "accel-display";
else if (data->info == &kxcj91008_kiox020a_info)
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 4/4] iio: accel: kxcjk-1013: Deduplicate ODR startup time array
2024-11-01 13:16 [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data() Andy Shevchenko
` (2 preceding siblings ...)
2024-11-01 13:16 ` [PATCH v3 3/4] iio: accel: kxcjk-1013: Assign NULL to ddata in kxcjk1013_probe() Andy Shevchenko
@ 2024-11-01 13:16 ` Andy Shevchenko
2024-11-01 14:59 ` [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data() Jonathan Cameron
4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-11-01 13:16 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko, linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen
The content of kxcj91008_odr_start_up_times and kxcjk1013_odr_start_up_times
is identical, deduplicate it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/accel/kxcjk-1013.c | 25 ++++---------------------
1 file changed, 4 insertions(+), 21 deletions(-)
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index 753ec2f71a9a..f65fde06f2c1 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -193,23 +193,6 @@ static const struct kx_odr_start_up_time kxcjk1013_odr_start_up_times[] = {
{ }
};
-/* KXCJ9-1008 */
-static const struct kx_odr_start_up_time kxcj91008_odr_start_up_times[] = {
- { 0x08, 100000 },
- { 0x09, 100000 },
- { 0x0A, 100000 },
- { 0x0B, 100000 },
- { 0x00, 80000 },
- { 0x01, 41000 },
- { 0x02, 21000 },
- { 0x03, 11000 },
- { 0x04, 6400 },
- { 0x05, 3900 },
- { 0x06, 2700 },
- { 0x07, 2100 },
- { }
-};
-
/* KXCTJ2-1009 */
static const struct kx_odr_start_up_time kxtj21009_odr_start_up_times[] = {
{ 0x08, 1240000 },
@@ -325,24 +308,24 @@ static const struct kx_chipset_info kxcjk1013_info = {
static const struct kx_chipset_info kxcj91008_info = {
.regs = &kxcjk1013_regs,
- .times = pm_ptr(kxcj91008_odr_start_up_times),
+ .times = pm_ptr(kxcjk1013_odr_start_up_times),
};
static const struct kx_chipset_info kxcj91008_kiox010a_info = {
.regs = &kxcjk1013_regs,
- .times = pm_ptr(kxcj91008_odr_start_up_times),
+ .times = pm_ptr(kxcjk1013_odr_start_up_times),
.acpi_type = ACPI_KIOX010A,
};
static const struct kx_chipset_info kxcj91008_kiox020a_info = {
.regs = &kxcjk1013_regs,
- .times = pm_ptr(kxcj91008_odr_start_up_times),
+ .times = pm_ptr(kxcjk1013_odr_start_up_times),
.acpi_type = ACPI_GENERIC,
};
static const struct kx_chipset_info kxcj91008_smo8500_info = {
.regs = &kxcjk1013_regs,
- .times = pm_ptr(kxcj91008_odr_start_up_times),
+ .times = pm_ptr(kxcjk1013_odr_start_up_times),
.acpi_type = ACPI_SMO8500,
};
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data()
2024-11-01 13:16 [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data() Andy Shevchenko
` (3 preceding siblings ...)
2024-11-01 13:16 ` [PATCH v3 4/4] iio: accel: kxcjk-1013: Deduplicate ODR startup time array Andy Shevchenko
@ 2024-11-01 14:59 ` Jonathan Cameron
2024-11-01 16:42 ` Andy Shevchenko
4 siblings, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2024-11-01 14:59 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jonathan Cameron, linux-iio, linux-kernel, Lars-Peter Clausen
On Fri, 1 Nov 2024 15:16:00 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> Dan reported that ddata might be used uninitialised in some cases.
> Let's initialise it to NULL (patches 1 - 3). With that, update one driver
> to drop an unneeded anymore check (included in patch 3).
>
> While at it, one more cleanup to kxcjk-1013 (patch 4) is added.
>
> Jonathan, dunno if you want to rebase at this stage (probably not),
> but if you do, feel free to fold the patches 1-3 to the initial code.
Ah. I've just picked v2, but given I squashed anyway the commit message
changes don't matter. I was curious what Assing meant but not need to
ask given I wasn't going to keep it.
Jonathan
>
> In v3:
> - made Subject more specific for patches 1-3 (Markus)
>
> In v2:
> - rewritten patches 1-3 to do the job on the caller side (Jonathan)
>
> Andy Shevchenko (4):
> iio: light: isl29018: Assign NULL to ddata in isl29018_probe()
> iio: light: ltr501: Assign NULL to ddata in ltr501_probe()
> iio: accel: kxcjk-1013: Assign NULL to ddata in kxcjk1013_probe()
> iio: accel: kxcjk-1013: Deduplicate ODR startup time array
>
> drivers/iio/accel/kxcjk-1013.c | 30 ++++++------------------------
> drivers/iio/light/isl29018.c | 2 +-
> drivers/iio/light/ltr501.c | 2 +-
> 3 files changed, 8 insertions(+), 26 deletions(-)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data()
2024-11-01 14:59 ` [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data() Jonathan Cameron
@ 2024-11-01 16:42 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-11-01 16:42 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Jonathan Cameron, linux-iio, linux-kernel, Lars-Peter Clausen
On Fri, Nov 01, 2024 at 02:59:38PM +0000, Jonathan Cameron wrote:
> On Fri, 1 Nov 2024 15:16:00 +0200
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
> > Dan reported that ddata might be used uninitialised in some cases.
> > Let's initialise it to NULL (patches 1 - 3). With that, update one driver
> > to drop an unneeded anymore check (included in patch 3).
> >
> > While at it, one more cleanup to kxcjk-1013 (patch 4) is added.
> >
> > Jonathan, dunno if you want to rebase at this stage (probably not),
> > but if you do, feel free to fold the patches 1-3 to the initial code.
> Ah. I've just picked v2, but given I squashed anyway the commit message
> changes don't matter.
Thanks, I have looked into the resulting changes and it all LGTM!
> I was curious what Assing meant but not need to
> ask given I wasn't going to keep it.
He-he :-)
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-11-01 16:42 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-01 13:16 [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data() Andy Shevchenko
2024-11-01 13:16 ` [PATCH v3 1/4] iio: light: isl29018: Assign NULL to ddata in isl29018_probe() Andy Shevchenko
2024-11-01 13:16 ` [PATCH v3 2/4] iio: light: ltr501: Assign NULL to ddata in ltr501_probe() Andy Shevchenko
2024-11-01 13:16 ` [PATCH v3 3/4] iio: accel: kxcjk-1013: Assign NULL to ddata in kxcjk1013_probe() Andy Shevchenko
2024-11-01 13:16 ` [PATCH v3 4/4] iio: accel: kxcjk-1013: Deduplicate ODR startup time array Andy Shevchenko
2024-11-01 14:59 ` [PATCH v3 0/4] iio: initialise ddata for iio_get_acpi_device_name_and_data() Jonathan Cameron
2024-11-01 16:42 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox