* [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
@ 2014-12-18 17:16 Daniel Baluta
2014-12-19 22:16 ` Hartmut Knaack
0 siblings, 1 reply; 18+ messages in thread
From: Daniel Baluta @ 2014-12-18 17:16 UTC (permalink / raw)
To: jic23
Cc: knaack.h, lars, pmeerw, gwendal, srinivas.pandruvada, beomho.seo,
daniel.baluta, linux-iio, linux-kernel, octavian.purdila
When using ACPI, if acpi_match_device fails then chipset enum will be
uninitialized and &ak_def_array[chipset] will point to some bad address.
This fixes the following compilation warning:
drivers/iio/magnetometer/ak8975.c: In function ‘ak8975_probe’:
drivers/iio/magnetometer/ak8975.c:788:14: warning: ‘chipset’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
data->def = &ak_def_array[chipset];
Reported-by: Octavian Purdila <octavian.purdila@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
---
This is a RFC because while I'm pretty sure that chipset should be initialized
with AK_MAX_TYPE in ak8975_match_acpi_device, I am not sure if we can live with
a NULL return value of ak8975_match_acpi_device. Current implementation ignores
return value of ak8975_match_acpi_device.
The same situation is for kxcjk-1013, bmc150-accel, bmg160 and possible other
drivers.
drivers/iio/magnetometer/ak8975.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 0d10a4b..cdf9e77 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -716,6 +716,7 @@ static const char *ak8975_match_acpi_device(struct device *dev,
{
const struct acpi_device_id *id;
+ *chipset = AK_MAX_TYPE;
id = acpi_match_device(dev->driver->acpi_match_table, dev);
if (!id)
return NULL;
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
2014-12-18 17:16 [RFC PATCH] iio: ak8975: Make sure chipset is always initialized Daniel Baluta
@ 2014-12-19 22:16 ` Hartmut Knaack
2014-12-19 22:25 ` Daniel Baluta
0 siblings, 1 reply; 18+ messages in thread
From: Hartmut Knaack @ 2014-12-19 22:16 UTC (permalink / raw)
To: Daniel Baluta, jic23
Cc: lars, pmeerw, gwendal, srinivas.pandruvada, beomho.seo, linux-iio,
linux-kernel, octavian.purdila
Daniel Baluta schrieb am 18.12.2014 um 18:16:
> When using ACPI, if acpi_match_device fails then chipset enum will be
> uninitialized and &ak_def_array[chipset] will point to some bad address.
>
> This fixes the following compilation warning:
>
> drivers/iio/magnetometer/ak8975.c: In function ‘ak8975_probe’:
> drivers/iio/magnetometer/ak8975.c:788:14: warning: ‘chipset’ may be used
> uninitialized in this function [-Wmaybe-uninitialized]
> data->def =ak_def_array[chipset];
>
> Reported-by: Octavian Purdila <octavian.purdila@intel.com>
> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
> ---
> This is a RFC because while I'm pretty sure that chipset should be initialized
> with AK_MAX_TYPE in ak8975_match_acpi_device, I am not sure if we can live with
> a NULL return value of ak8975_match_acpi_device. Current implementation ignores
> return value of ak8975_match_acpi_device.
This seems to be the actual problem: these _match_acpi_device functions return
NULL on failure, and this should be checked for.
>
> The same situation is for kxcjk-1013, bmc150-accel, bmg160 and possible other
> drivers.
>
> drivers/iio/magnetometer/ak8975.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
> index 0d10a4b..cdf9e77 100644
> --- a/drivers/iio/magnetometer/ak8975.c
> +++ b/drivers/iio/magnetometer/ak8975.c
> @@ -716,6 +716,7 @@ static const char *ak8975_match_acpi_device(struct device *dev,
> {
> const struct acpi_device_id *id;
>
> + *chipset =K_MAX_TYPE;
> id =cpi_match_device(dev->driver->acpi_match_table, dev);
> if (!id)
> return NULL;
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
2014-12-19 22:16 ` Hartmut Knaack
@ 2014-12-19 22:25 ` Daniel Baluta
0 siblings, 0 replies; 18+ messages in thread
From: Daniel Baluta @ 2014-12-19 22:25 UTC (permalink / raw)
To: Hartmut Knaack
Cc: Daniel Baluta, Jonathan Cameron, Lars-Peter Clausen,
Peter Meerwald, gwendal, Srinivas Pandruvada, beomho.seo,
linux-iio@vger.kernel.org, Linux Kernel Mailing List,
octavian.purdila@intel.com
On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
> Daniel Baluta schrieb am 18.12.2014 um 18:16:
>> When using ACPI, if acpi_match_device fails then chipset enum will be
>> uninitialized and &ak_def_array[chipset] will point to some bad address.
>>
>> This fixes the following compilation warning:
>>
>> drivers/iio/magnetometer/ak8975.c: In function =E2=80=98ak8975_probe=E2=
=80=99:
>> drivers/iio/magnetometer/ak8975.c:788:14: warning: =E2=80=98chipset=E2=
=80=99 may be used
>> uninitialized in this function [-Wmaybe-uninitialized]
>> data->def =3Dak_def_array[chipset];
>>
>> Reported-by: Octavian Purdila <octavian.purdila@intel.com>
>> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
>> ---
>> This is a RFC because while I'm pretty sure that chipset should be initi=
alized
>> with AK_MAX_TYPE in ak8975_match_acpi_device, I am not sure if we can li=
ve with
>> a NULL return value of ak8975_match_acpi_device. Current implementation =
ignores
>> return value of ak8975_match_acpi_device.
> This seems to be the actual problem: these _match_acpi_device functions r=
eturn
> NULL on failure, and this should be checked for.
Ok, so this would acceptable?
diff --git a/drivers/iio/magnetometer/ak8975.c
b/drivers/iio/magnetometer/ak8975.c
index 0d10a4b..68d99e9 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -776,8 +776,9 @@ static int ak8975_probe(struct i2c_client *client,
name =3D id->name;
} else if (ACPI_HANDLE(&client->dev))
name =3D ak8975_match_acpi_device(&client->dev, &chipset);
- else
- return -ENOSYS;
+
+ if (!name)
+ return -ENODEV;
I still have some doubts about return code in case of error.
For ak8975 we use -ENOSYS, but for kxcjk-1013 we use -ENODEV.
I will send a patch after we clear this out.
thanks,
Daniel.
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
@ 2014-12-19 22:25 ` Daniel Baluta
0 siblings, 0 replies; 18+ messages in thread
From: Daniel Baluta @ 2014-12-19 22:25 UTC (permalink / raw)
To: Hartmut Knaack
Cc: Daniel Baluta, Jonathan Cameron, Lars-Peter Clausen,
Peter Meerwald, gwendal, Srinivas Pandruvada, beomho.seo,
linux-iio@vger.kernel.org, Linux Kernel Mailing List,
octavian.purdila@intel.com
On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
> Daniel Baluta schrieb am 18.12.2014 um 18:16:
>> When using ACPI, if acpi_match_device fails then chipset enum will be
>> uninitialized and &ak_def_array[chipset] will point to some bad address.
>>
>> This fixes the following compilation warning:
>>
>> drivers/iio/magnetometer/ak8975.c: In function ‘ak8975_probe’:
>> drivers/iio/magnetometer/ak8975.c:788:14: warning: ‘chipset’ may be used
>> uninitialized in this function [-Wmaybe-uninitialized]
>> data->def =ak_def_array[chipset];
>>
>> Reported-by: Octavian Purdila <octavian.purdila@intel.com>
>> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
>> ---
>> This is a RFC because while I'm pretty sure that chipset should be initialized
>> with AK_MAX_TYPE in ak8975_match_acpi_device, I am not sure if we can live with
>> a NULL return value of ak8975_match_acpi_device. Current implementation ignores
>> return value of ak8975_match_acpi_device.
> This seems to be the actual problem: these _match_acpi_device functions return
> NULL on failure, and this should be checked for.
Ok, so this would acceptable?
diff --git a/drivers/iio/magnetometer/ak8975.c
b/drivers/iio/magnetometer/ak8975.c
index 0d10a4b..68d99e9 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -776,8 +776,9 @@ static int ak8975_probe(struct i2c_client *client,
name = id->name;
} else if (ACPI_HANDLE(&client->dev))
name = ak8975_match_acpi_device(&client->dev, &chipset);
- else
- return -ENOSYS;
+
+ if (!name)
+ return -ENODEV;
I still have some doubts about return code in case of error.
For ak8975 we use -ENOSYS, but for kxcjk-1013 we use -ENODEV.
I will send a patch after we clear this out.
thanks,
Daniel.
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
2014-12-19 22:25 ` Daniel Baluta
(?)
@ 2014-12-20 21:26 ` Srinivas Pandruvada
2014-12-20 21:29 ` Pandruvada, Srinivas
-1 siblings, 1 reply; 18+ messages in thread
From: Srinivas Pandruvada @ 2014-12-20 21:26 UTC (permalink / raw)
To: Daniel Baluta
Cc: Hartmut Knaack, Jonathan Cameron, Lars-Peter Clausen,
Peter Meerwald, gwendal, beomho.seo, linux-iio@vger.kernel.org,
Linux Kernel Mailing List, octavian.purdila@intel.com
On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
> On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
> > Daniel Baluta schrieb am 18.12.2014 um 18:16:
> >> When using ACPI, if acpi_match_device fails then chipset enum will be
> >> uninitialized and &ak_def_array[chipset] will point to some bad address.
> >>
I am missing something. You are enumerated over i2c device, which was
created from ACPI PNP resource. There is a valid handle or and the
device has an ACPI companion at the least. If this failing, I have to
check the code for acpi i2c.
Can you check why this check failed? We may have bug in i2c handling.
Thanks,
Srinivas
> >> This fixes the following compilation warning:
> >>
> >> drivers/iio/magnetometer/ak8975.c: In function ‘ak8975_probe’:
> >> drivers/iio/magnetometer/ak8975.c:788:14: warning: ‘chipset’ may be used
> >> uninitialized in this function [-Wmaybe-uninitialized]
> >> data->def =ak_def_array[chipset];
> >>
> >> Reported-by: Octavian Purdila <octavian.purdila@intel.com>
> >> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
> >> ---
> >> This is a RFC because while I'm pretty sure that chipset should be initialized
> >> with AK_MAX_TYPE in ak8975_match_acpi_device, I am not sure if we can live with
> >> a NULL return value of ak8975_match_acpi_device. Current implementation ignores
> >> return value of ak8975_match_acpi_device.
> > This seems to be the actual problem: these _match_acpi_device functions return
> > NULL on failure, and this should be checked for.
>
> Ok, so this would acceptable?
>
> diff --git a/drivers/iio/magnetometer/ak8975.c
> b/drivers/iio/magnetometer/ak8975.c
> index 0d10a4b..68d99e9 100644
> --- a/drivers/iio/magnetometer/ak8975.c
> +++ b/drivers/iio/magnetometer/ak8975.c
> @@ -776,8 +776,9 @@ static int ak8975_probe(struct i2c_client *client,
> name = id->name;
> } else if (ACPI_HANDLE(&client->dev))
> name = ak8975_match_acpi_device(&client->dev, &chipset);
> - else
> - return -ENOSYS;
> +
> + if (!name)
> + return -ENODEV;
>
>
> I still have some doubts about return code in case of error.
>
> For ak8975 we use -ENOSYS, but for kxcjk-1013 we use -ENODEV.
>
> I will send a patch after we clear this out.
>
> thanks,
> Daniel.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
2014-12-20 21:26 ` Srinivas Pandruvada
@ 2014-12-20 21:29 ` Pandruvada, Srinivas
0 siblings, 0 replies; 18+ messages in thread
From: Pandruvada, Srinivas @ 2014-12-20 21:29 UTC (permalink / raw)
To: Baluta, Daniel
Cc: lars@metafoo.de, linux-kernel@vger.kernel.org, knaack.h@gmx.de,
jic23@kernel.org, Purdila, Octavian, linux-iio@vger.kernel.org,
Westerberg, Mika, pmeerw@pmeerw.net, beomho.seo@samsung.com,
gwendal@chromium.org
K01pa2ENCg0KT24gU2F0LCAyMDE0LTEyLTIwIGF0IDEzOjI2IC0wODAwLCBTcmluaXZhcyBQYW5k
cnV2YWRhIHdyb3RlOg0KPiBPbiBTYXQsIDIwMTQtMTItMjAgYXQgMDA6MjUgKzAyMDAsIERhbmll
bCBCYWx1dGEgd3JvdGU6DQo+ID4gT24gU2F0LCBEZWMgMjAsIDIwMTQgYXQgMTI6MTYgQU0sIEhh
cnR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
SSB3aWxsIHNlbmQgYSBwYXRjaCBhZnRlciB3ZSBjbGVhciB0aGlzIG91dC4NCj4gPiANCj4gPiB0
aGFua3MsDQo+ID4gRGFuaWVsLg0KPiANCg0K
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
@ 2014-12-20 21:29 ` Pandruvada, Srinivas
0 siblings, 0 replies; 18+ messages in thread
From: Pandruvada, Srinivas @ 2014-12-20 21:29 UTC (permalink / raw)
To: Baluta, Daniel
Cc: lars@metafoo.de, linux-kernel@vger.kernel.org, knaack.h@gmx.de,
jic23@kernel.org, Purdila, Octavian, linux-iio@vger.kernel.org,
Westerberg, Mika, pmeerw@pmeerw.net, beomho.seo@samsung.com,
gwendal@chromium.org
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2689 bytes --]
+Mika
On Sat, 2014-12-20 at 13:26 -0800, Srinivas Pandruvada wrote:
> On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
> > On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
> > > Daniel Baluta schrieb am 18.12.2014 um 18:16:
> > >> When using ACPI, if acpi_match_device fails then chipset enum will be
> > >> uninitialized and &ak_def_array[chipset] will point to some bad address.
> > >>
> I am missing something. You are enumerated over i2c device, which was
> created from ACPI PNP resource. There is a valid handle or and the
> device has an ACPI companion at the least. If this failing, I have to
> check the code for acpi i2c.
> Can you check why this check failed? We may have bug in i2c handling.
>
> Thanks,
> Srinivas
>
> > >> This fixes the following compilation warning:
> > >>
> > >> drivers/iio/magnetometer/ak8975.c: In function âak8975_probeâ:
> > >> drivers/iio/magnetometer/ak8975.c:788:14: warning: âchipsetâ may be used
> > >> uninitialized in this function [-Wmaybe-uninitialized]
> > >> data->def =ak_def_array[chipset];
> > >>
> > >> Reported-by: Octavian Purdila <octavian.purdila@intel.com>
> > >> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
> > >> ---
> > >> This is a RFC because while I'm pretty sure that chipset should be initialized
> > >> with AK_MAX_TYPE in ak8975_match_acpi_device, I am not sure if we can live with
> > >> a NULL return value of ak8975_match_acpi_device. Current implementation ignores
> > >> return value of ak8975_match_acpi_device.
> > > This seems to be the actual problem: these _match_acpi_device functions return
> > > NULL on failure, and this should be checked for.
> >
> > Ok, so this would acceptable?
> >
> > diff --git a/drivers/iio/magnetometer/ak8975.c
> > b/drivers/iio/magnetometer/ak8975.c
> > index 0d10a4b..68d99e9 100644
> > --- a/drivers/iio/magnetometer/ak8975.c
> > +++ b/drivers/iio/magnetometer/ak8975.c
> > @@ -776,8 +776,9 @@ static int ak8975_probe(struct i2c_client *client,
> > name = id->name;
> > } else if (ACPI_HANDLE(&client->dev))
> > name = ak8975_match_acpi_device(&client->dev, &chipset);
> > - else
> > - return -ENOSYS;
> > +
> > + if (!name)
> > + return -ENODEV;
> >
> >
> > I still have some doubts about return code in case of error.
> >
> > For ak8975 we use -ENOSYS, but for kxcjk-1013 we use -ENODEV.
> >
> > I will send a patch after we clear this out.
> >
> > thanks,
> > Daniel.
>
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
2014-12-20 21:29 ` Pandruvada, Srinivas
@ 2014-12-20 21:40 ` Daniel Baluta
-1 siblings, 0 replies; 18+ messages in thread
From: Daniel Baluta @ 2014-12-20 21:40 UTC (permalink / raw)
To: Pandruvada, Srinivas
Cc: Baluta, Daniel, lars@metafoo.de, linux-kernel@vger.kernel.org,
knaack.h@gmx.de, jic23@kernel.org, Purdila, Octavian,
linux-iio@vger.kernel.org, Westerberg, Mika, pmeerw@pmeerw.net,
beomho.seo@samsung.com, gwendal@chromium.org
I will have closer look on why acpi_match_device could fail. This patch
was only based on code reading when trying to fix the compiler warning
mentioned in the commit message.
[Sorry for top posting]
On Sat, Dec 20, 2014 at 11:29 PM, Pandruvada, Srinivas
<srinivas.pandruvada@intel.com> wrote:
> +Mika
>
> On Sat, 2014-12-20 at 13:26 -0800, Srinivas Pandruvada wrote:
>> On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
>> > On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wro=
te:
>> > > Daniel Baluta schrieb am 18.12.2014 um 18:16:
>> > >> When using ACPI, if acpi_match_device fails then chipset enum will =
be
>> > >> uninitialized and &ak_def_array[chipset] will point to some bad add=
ress.
>> > >>
>> I am missing something. You are enumerated over i2c device, which was
>> created from ACPI PNP resource. There is a valid handle or and the
>> device has an ACPI companion at the least. If this failing, I have to
>> check the code for acpi i2c.
>> Can you check why this check failed? We may have bug in i2c handling.
>>
>> Thanks,
>> Srinivas
>>
>> > >> This fixes the following compilation warning:
>> > >>
>> > >> drivers/iio/magnetometer/ak8975.c: In function =E2=80=98ak8975_prob=
e=E2=80=99:
>> > >> drivers/iio/magnetometer/ak8975.c:788:14: warning: =E2=80=98chipset=
=E2=80=99 may be used
>> > >> uninitialized in this function [-Wmaybe-uninitialized]
>> > >> data->def =3Dak_def_array[chipset];
>> > >>
>> > >> Reported-by: Octavian Purdila <octavian.purdila@intel.com>
>> > >> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
>> > >> ---
>> > >> This is a RFC because while I'm pretty sure that chipset should be =
initialized
>> > >> with AK_MAX_TYPE in ak8975_match_acpi_device, I am not sure if we c=
an live with
>> > >> a NULL return value of ak8975_match_acpi_device. Current implementa=
tion ignores
>> > >> return value of ak8975_match_acpi_device.
>> > > This seems to be the actual problem: these _match_acpi_device functi=
ons return
>> > > NULL on failure, and this should be checked for.
>> >
>> > Ok, so this would acceptable?
>> >
>> > diff --git a/drivers/iio/magnetometer/ak8975.c
>> > b/drivers/iio/magnetometer/ak8975.c
>> > index 0d10a4b..68d99e9 100644
>> > --- a/drivers/iio/magnetometer/ak8975.c
>> > +++ b/drivers/iio/magnetometer/ak8975.c
>> > @@ -776,8 +776,9 @@ static int ak8975_probe(struct i2c_client *client,
>> > name =3D id->name;
>> > } else if (ACPI_HANDLE(&client->dev))
>> > name =3D ak8975_match_acpi_device(&client->dev, &chips=
et);
>> > - else
>> > - return -ENOSYS;
>> > +
>> > + if (!name)
>> > + return -ENODEV;
>> >
>> >
>> > I still have some doubts about return code in case of error.
>> >
>> > For ak8975 we use -ENOSYS, but for kxcjk-1013 we use -ENODEV.
>> >
>> > I will send a patch after we clear this out.
>> >
>> > thanks,
>> > Daniel.
>>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
@ 2014-12-20 21:40 ` Daniel Baluta
0 siblings, 0 replies; 18+ messages in thread
From: Daniel Baluta @ 2014-12-20 21:40 UTC (permalink / raw)
To: Pandruvada, Srinivas
Cc: Baluta, Daniel, lars@metafoo.de, linux-kernel@vger.kernel.org,
knaack.h@gmx.de, jic23@kernel.org, Purdila, Octavian,
linux-iio@vger.kernel.org, Westerberg, Mika, pmeerw@pmeerw.net,
beomho.seo@samsung.com, gwendal@chromium.org
I will have closer look on why acpi_match_device could fail. This patch
was only based on code reading when trying to fix the compiler warning
mentioned in the commit message.
[Sorry for top posting]
On Sat, Dec 20, 2014 at 11:29 PM, Pandruvada, Srinivas
<srinivas.pandruvada@intel.com> wrote:
> +Mika
>
> On Sat, 2014-12-20 at 13:26 -0800, Srinivas Pandruvada wrote:
>> On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
>> > On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
>> > > Daniel Baluta schrieb am 18.12.2014 um 18:16:
>> > >> When using ACPI, if acpi_match_device fails then chipset enum will be
>> > >> uninitialized and &ak_def_array[chipset] will point to some bad address.
>> > >>
>> I am missing something. You are enumerated over i2c device, which was
>> created from ACPI PNP resource. There is a valid handle or and the
>> device has an ACPI companion at the least. If this failing, I have to
>> check the code for acpi i2c.
>> Can you check why this check failed? We may have bug in i2c handling.
>>
>> Thanks,
>> Srinivas
>>
>> > >> This fixes the following compilation warning:
>> > >>
>> > >> drivers/iio/magnetometer/ak8975.c: In function ‘ak8975_probe’:
>> > >> drivers/iio/magnetometer/ak8975.c:788:14: warning: ‘chipset’ may be used
>> > >> uninitialized in this function [-Wmaybe-uninitialized]
>> > >> data->def =ak_def_array[chipset];
>> > >>
>> > >> Reported-by: Octavian Purdila <octavian.purdila@intel.com>
>> > >> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
>> > >> ---
>> > >> This is a RFC because while I'm pretty sure that chipset should be initialized
>> > >> with AK_MAX_TYPE in ak8975_match_acpi_device, I am not sure if we can live with
>> > >> a NULL return value of ak8975_match_acpi_device. Current implementation ignores
>> > >> return value of ak8975_match_acpi_device.
>> > > This seems to be the actual problem: these _match_acpi_device functions return
>> > > NULL on failure, and this should be checked for.
>> >
>> > Ok, so this would acceptable?
>> >
>> > diff --git a/drivers/iio/magnetometer/ak8975.c
>> > b/drivers/iio/magnetometer/ak8975.c
>> > index 0d10a4b..68d99e9 100644
>> > --- a/drivers/iio/magnetometer/ak8975.c
>> > +++ b/drivers/iio/magnetometer/ak8975.c
>> > @@ -776,8 +776,9 @@ static int ak8975_probe(struct i2c_client *client,
>> > name = id->name;
>> > } else if (ACPI_HANDLE(&client->dev))
>> > name = ak8975_match_acpi_device(&client->dev, &chipset);
>> > - else
>> > - return -ENOSYS;
>> > +
>> > + if (!name)
>> > + return -ENODEV;
>> >
>> >
>> > I still have some doubts about return code in case of error.
>> >
>> > For ak8975 we use -ENOSYS, but for kxcjk-1013 we use -ENODEV.
>> >
>> > I will send a patch after we clear this out.
>> >
>> > thanks,
>> > Daniel.
>>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
2014-12-20 21:29 ` Pandruvada, Srinivas
(?)
(?)
@ 2015-01-19 14:40 ` Daniel Baluta
2015-01-19 16:44 ` Pandruvada, Srinivas
-1 siblings, 1 reply; 18+ messages in thread
From: Daniel Baluta @ 2015-01-19 14:40 UTC (permalink / raw)
To: Pandruvada, Srinivas
Cc: Baluta, Daniel, lars@metafoo.de, linux-kernel@vger.kernel.org,
knaack.h@gmx.de, jic23@kernel.org, Purdila, Octavian,
linux-iio@vger.kernel.org, Westerberg, Mika, pmeerw@pmeerw.net,
beomho.seo@samsung.com, gwendal@chromium.org
Hello,
On Sat, Dec 20, 2014 at 11:29 PM, Pandruvada, Srinivas
<srinivas.pandruvada@intel.com> wrote:
> +Mika
>
> On Sat, 2014-12-20 at 13:26 -0800, Srinivas Pandruvada wrote:
>> On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
>> > On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
>> > > Daniel Baluta schrieb am 18.12.2014 um 18:16:
>> > >> When using ACPI, if acpi_match_device fails then chipset enum will be
>> > >> uninitialized and &ak_def_array[chipset] will point to some bad address.
>> > >>
>> I am missing something. You are enumerated over i2c device, which was
>> created from ACPI PNP resource. There is a valid handle or and the
>> device has an ACPI companion at the least. If this failing, I have to
>> check the code for acpi i2c.
>> Can you check why this check failed? We may have bug in i2c handling.
You are right about this. Under normal circumstances, if probe is called
then acpi_match_device will not fail. I even tried to remove the
device after probe
but before acpi_match_device, anyhow acpi_match_device was still successful :)
This is more a matter of code correctness.
In ak8975_match_acpi_device we have:
» const struct acpi_device_id *id;
» id = acpi_match_device(dev->driver->acpi_match_table, dev);
» if (!id)
» » return NULL;
» *chipset = (int)id->driver_data;
Compiler complains on the fact that chipset might be uninitialized
if this returns NULL, and we shouldn't ignore this warning even this case
will never happen.
We could use some code injection techniques to force acpi_match_device
to return NULL tough.
>> > >> This fixes the following compilation warning:
>> > >>
>> > >> drivers/iio/magnetometer/ak8975.c: In function ‘ak8975_probe’:
>> > >> drivers/iio/magnetometer/ak8975.c:788:14: warning: ‘chipset’ may be used
>> > >> uninitialized in this function [-Wmaybe-uninitialized]
>> > >> data->def =ak_def_array[chipset];
>> > >>
>> > >> Reported-by: Octavian Purdila <octavian.purdila@intel.com>
>> > >> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
>> > >> ---
>> > >> This is a RFC because while I'm pretty sure that chipset should be initialized
>> > >> with AK_MAX_TYPE in ak8975_match_acpi_device, I am not sure if we can live with
>> > >> a NULL return value of ak8975_match_acpi_device. Current implementation ignores
>> > >> return value of ak8975_match_acpi_device.
>> > > This seems to be the actual problem: these _match_acpi_device functions return
>> > > NULL on failure, and this should be checked for.
>> >
>> > Ok, so this would acceptable?
>> >
>> > diff --git a/drivers/iio/magnetometer/ak8975.c
>> > b/drivers/iio/magnetometer/ak8975.c
>> > index 0d10a4b..68d99e9 100644
>> > --- a/drivers/iio/magnetometer/ak8975.c
>> > +++ b/drivers/iio/magnetometer/ak8975.c
>> > @@ -776,8 +776,9 @@ static int ak8975_probe(struct i2c_client *client,
>> > name = id->name;
>> > } else if (ACPI_HANDLE(&client->dev))
>> > name = ak8975_match_acpi_device(&client->dev, &chipset);
>> > - else
>> > - return -ENOSYS;
>> > +
>> > + if (!name)
>> > + return -ENODEV;
>> >
>> >
>> > I still have some doubts about return code in case of error.
>> >
>> > For ak8975 we use -ENOSYS, but for kxcjk-1013 we use -ENODEV.
>> >
>> > I will send a patch after we clear this out.
>> >
>> > thanks,
>> > Daniel.
>>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
2015-01-19 14:40 ` Daniel Baluta
@ 2015-01-19 16:44 ` Pandruvada, Srinivas
0 siblings, 0 replies; 18+ messages in thread
From: Pandruvada, Srinivas @ 2015-01-19 16:44 UTC (permalink / raw)
To: Baluta, Daniel
Cc: lars@metafoo.de, linux-kernel@vger.kernel.org, knaack.h@gmx.de,
jic23@kernel.org, Purdila, Octavian, linux-iio@vger.kernel.org,
Westerberg, Mika, pmeerw@pmeerw.net, beomho.seo@samsung.com,
gwendal@chromium.org
T24gTW9uLCAyMDE1LTAxLTE5IGF0IDE2OjQwICswMjAwLCBEYW5pZWwgQmFsdXRhIHdyb3RlOiAN
Cj4gSGVsbG8sDQo+IA0KPiBPbiBTYXQsIERlYyAyMCwgMjAxNCBhdCAxMToyOSBQTSwgUGFuZHJ1
dmFkYSwgU3Jpbml2YXMNCj4gPHNyaW5pdmFzLnBhbmRydXZhZGFAaW50ZWwuY29tPiB3cm90ZToN
Cj4gPiArTWlrYQ0KPiA+DQo+ID4gT24gU2F0LCAyMDE0LTEyLTIwIGF0IDEzOjI2IC0wODAwLCBT
cmluaXZhcyBQYW5kcnV2YWRhIHdyb3RlOg0KPiA+PiBPbiBTYXQsIDIwMTQtMTItMjAgYXQgMDA6
MjUgKzAyMDAsIERhbmllbCBCYWx1dGEgd3JvdGU6DQo+ID4+ID4gT24gU2F0LCBEZWMgMjAsIDIw
MTQgYXQgMTI6MTYgQU0sIEhhcnRtdXQgS25hYWNrIDxrbmFhY2suaEBnbXguZGU+IHdyb3RlOg0K
PiA+PiA+ID4gRGFuaWVsIEJhbHV0YSBzY2hyaWViIGFtIDE4LjEyLjIwMTQgdW0gMTg6MTY6DQo+
ID4+ID4gPj4gV2hlbiB1c2luZyBBQ1BJLCBpZiBhY3BpX21hdGNoX2RldmljZSBmYWlscyB0aGVu
IGNoaXBzZXQgZW51bSB3aWxsIGJlDQo+ID4+ID4gPj4gdW5pbml0aWFsaXplZCBhbmQgJmFrX2Rl
Zl9hcnJheVtjaGlwc2V0XSB3aWxsIHBvaW50IHRvIHNvbWUgYmFkIGFkZHJlc3Mu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reGNqay0xMDEzIHdlIHVzZSAt
RU5PREVWLg0KPiA+PiA+DQo+ID4+ID4gSSB3aWxsIHNlbmQgYSBwYXRjaCBhZnRlciB3ZSBjbGVh
ciB0aGlzIG91dC4NCj4gPj4gPg0KPiA+PiA+IHRoYW5rcywNCj4gPj4gPiBEYW5pZWwuDQo+ID4+
DQo+ID4NCg0K
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
@ 2015-01-19 16:44 ` Pandruvada, Srinivas
0 siblings, 0 replies; 18+ messages in thread
From: Pandruvada, Srinivas @ 2015-01-19 16:44 UTC (permalink / raw)
To: Baluta, Daniel
Cc: lars@metafoo.de, linux-kernel@vger.kernel.org, knaack.h@gmx.de,
jic23@kernel.org, Purdila, Octavian, linux-iio@vger.kernel.org,
Westerberg, Mika, pmeerw@pmeerw.net, beomho.seo@samsung.com,
gwendal@chromium.org
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3949 bytes --]
On Mon, 2015-01-19 at 16:40 +0200, Daniel Baluta wrote:
> Hello,
>
> On Sat, Dec 20, 2014 at 11:29 PM, Pandruvada, Srinivas
> <srinivas.pandruvada@intel.com> wrote:
> > +Mika
> >
> > On Sat, 2014-12-20 at 13:26 -0800, Srinivas Pandruvada wrote:
> >> On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
> >> > On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
> >> > > Daniel Baluta schrieb am 18.12.2014 um 18:16:
> >> > >> When using ACPI, if acpi_match_device fails then chipset enum will be
> >> > >> uninitialized and &ak_def_array[chipset] will point to some bad address.
> >> > >>
> >> I am missing something. You are enumerated over i2c device, which was
> >> created from ACPI PNP resource. There is a valid handle or and the
> >> device has an ACPI companion at the least. If this failing, I have to
> >> check the code for acpi i2c.
> >> Can you check why this check failed? We may have bug in i2c handling.
>
> You are right about this. Under normal circumstances, if probe is called
> then acpi_match_device will not fail. I even tried to remove the
> device after probe
> but before acpi_match_device, anyhow acpi_match_device was still successful :)
>
> This is more a matter of code correctness.
>
> In ak8975_match_acpi_device we have:
>
> » const struct acpi_device_id *id;
>
> » id = acpi_match_device(dev->driver->acpi_match_table, dev);
> » if (!id)
> » » return NULL;
> » *chipset = (int)id->driver_data;
>
> Compiler complains on the fact that chipset might be uninitialized
> if this returns NULL, and we shouldn't ignore this warning even this case
> will never happen.
>
Will this fix?
data->chipset = AK8975;
before
ak8975_match_acpi_device(&client->dev, &data->chipset);
Thanks,
Srinivas
> We could use some code injection techniques to force acpi_match_device
> to return NULL tough.
>
> >> > >> This fixes the following compilation warning:
> >> > >>
> >> > >> drivers/iio/magnetometer/ak8975.c: In function âak8975_probeâ:
> >> > >> drivers/iio/magnetometer/ak8975.c:788:14: warning: âchipsetâ may be used
> >> > >> uninitialized in this function [-Wmaybe-uninitialized]
> >> > >> data->def =ak_def_array[chipset];
> >> > >>
> >> > >> Reported-by: Octavian Purdila <octavian.purdila@intel.com>
> >> > >> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
> >> > >> ---
> >> > >> This is a RFC because while I'm pretty sure that chipset should be initialized
> >> > >> with AK_MAX_TYPE in ak8975_match_acpi_device, I am not sure if we can live with
> >> > >> a NULL return value of ak8975_match_acpi_device. Current implementation ignores
> >> > >> return value of ak8975_match_acpi_device.
> >> > > This seems to be the actual problem: these _match_acpi_device functions return
> >> > > NULL on failure, and this should be checked for.
> >> >
> >> > Ok, so this would acceptable?
> >> >
> >> > diff --git a/drivers/iio/magnetometer/ak8975.c
> >> > b/drivers/iio/magnetometer/ak8975.c
> >> > index 0d10a4b..68d99e9 100644
> >> > --- a/drivers/iio/magnetometer/ak8975.c
> >> > +++ b/drivers/iio/magnetometer/ak8975.c
> >> > @@ -776,8 +776,9 @@ static int ak8975_probe(struct i2c_client *client,
> >> > name = id->name;
> >> > } else if (ACPI_HANDLE(&client->dev))
> >> > name = ak8975_match_acpi_device(&client->dev, &chipset);
> >> > - else
> >> > - return -ENOSYS;
> >> > +
> >> > + if (!name)
> >> > + return -ENODEV;
> >> >
> >> >
> >> > I still have some doubts about return code in case of error.
> >> >
> >> > For ak8975 we use -ENOSYS, but for kxcjk-1013 we use -ENODEV.
> >> >
> >> > I will send a patch after we clear this out.
> >> >
> >> > thanks,
> >> > Daniel.
> >>
> >
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
2015-01-19 16:44 ` Pandruvada, Srinivas
(?)
@ 2015-01-19 16:49 ` Daniel Baluta
2015-01-19 16:56 ` Pandruvada, Srinivas
-1 siblings, 1 reply; 18+ messages in thread
From: Daniel Baluta @ 2015-01-19 16:49 UTC (permalink / raw)
To: Pandruvada, Srinivas
Cc: Baluta, Daniel, lars@metafoo.de, linux-kernel@vger.kernel.org,
knaack.h@gmx.de, jic23@kernel.org, Purdila, Octavian,
linux-iio@vger.kernel.org, Westerberg, Mika, pmeerw@pmeerw.net,
beomho.seo@samsung.com, gwendal@chromium.org
On Mon, Jan 19, 2015 at 6:44 PM, Pandruvada, Srinivas
<srinivas.pandruvada@intel.com> wrote:
> On Mon, 2015-01-19 at 16:40 +0200, Daniel Baluta wrote:
>> Hello,
>>
>> On Sat, Dec 20, 2014 at 11:29 PM, Pandruvada, Srinivas
>> <srinivas.pandruvada@intel.com> wrote:
>> > +Mika
>> >
>> > On Sat, 2014-12-20 at 13:26 -0800, Srinivas Pandruvada wrote:
>> >> On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
>> >> > On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
>> >> > > Daniel Baluta schrieb am 18.12.2014 um 18:16:
>> >> > >> When using ACPI, if acpi_match_device fails then chipset enum will be
>> >> > >> uninitialized and &ak_def_array[chipset] will point to some bad address.
>> >> > >>
>> >> I am missing something. You are enumerated over i2c device, which was
>> >> created from ACPI PNP resource. There is a valid handle or and the
>> >> device has an ACPI companion at the least. If this failing, I have to
>> >> check the code for acpi i2c.
>> >> Can you check why this check failed? We may have bug in i2c handling.
>>
>> You are right about this. Under normal circumstances, if probe is called
>> then acpi_match_device will not fail. I even tried to remove the
>> device after probe
>> but before acpi_match_device, anyhow acpi_match_device was still successful :)
>>
>> This is more a matter of code correctness.
>>
>> In ak8975_match_acpi_device we have:
>>
>> » const struct acpi_device_id *id;
>>
>> » id = acpi_match_device(dev->driver->acpi_match_table, dev);
>> » if (!id)
>> » » return NULL;
>> » *chipset = (int)id->driver_data;
>>
>> Compiler complains on the fact that chipset might be uninitialized
>> if this returns NULL, and we shouldn't ignore this warning even this case
>> will never happen.
>>
> Will this fix?
> data->chipset = AK8975;
> before
> ak8975_match_acpi_device(&client->dev, &data->chipset);
>
Yes, this is done in the original patch:
+ *chipset = AK_MAX_TYPE;
.. and fixes the warning.
Daniel.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
2015-01-19 16:49 ` Daniel Baluta
@ 2015-01-19 16:56 ` Pandruvada, Srinivas
0 siblings, 0 replies; 18+ messages in thread
From: Pandruvada, Srinivas @ 2015-01-19 16:56 UTC (permalink / raw)
To: Baluta, Daniel
Cc: lars@metafoo.de, linux-kernel@vger.kernel.org, knaack.h@gmx.de,
jic23@kernel.org, Purdila, Octavian, linux-iio@vger.kernel.org,
Westerberg, Mika, pmeerw@pmeerw.net, beomho.seo@samsung.com,
gwendal@chromium.org
T24gTW9uLCAyMDE1LTAxLT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aGUgd2FybmluZy4NCj4gDQo+IERhbmllbC4NCg0K
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
@ 2015-01-19 16:56 ` Pandruvada, Srinivas
0 siblings, 0 replies; 18+ messages in thread
From: Pandruvada, Srinivas @ 2015-01-19 16:56 UTC (permalink / raw)
To: Baluta, Daniel
Cc: lars@metafoo.de, linux-kernel@vger.kernel.org, knaack.h@gmx.de,
jic23@kernel.org, Purdila, Octavian, linux-iio@vger.kernel.org,
Westerberg, Mika, pmeerw@pmeerw.net, beomho.seo@samsung.com,
gwendal@chromium.org
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2471 bytes --]
On Mon, 2015-01-19 at 18:49 +0200, Daniel Baluta wrote:
> On Mon, Jan 19, 2015 at 6:44 PM, Pandruvada, Srinivas
> <srinivas.pandruvada@intel.com> wrote:
> > On Mon, 2015-01-19 at 16:40 +0200, Daniel Baluta wrote:
> >> Hello,
> >>
> >> On Sat, Dec 20, 2014 at 11:29 PM, Pandruvada, Srinivas
> >> <srinivas.pandruvada@intel.com> wrote:
> >> > +Mika
> >> >
> >> > On Sat, 2014-12-20 at 13:26 -0800, Srinivas Pandruvada wrote:
> >> >> On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
> >> >> > On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
> >> >> > > Daniel Baluta schrieb am 18.12.2014 um 18:16:
> >> >> > >> When using ACPI, if acpi_match_device fails then chipset enum will be
> >> >> > >> uninitialized and &ak_def_array[chipset] will point to some bad address.
> >> >> > >>
> >> >> I am missing something. You are enumerated over i2c device, which was
> >> >> created from ACPI PNP resource. There is a valid handle or and the
> >> >> device has an ACPI companion at the least. If this failing, I have to
> >> >> check the code for acpi i2c.
> >> >> Can you check why this check failed? We may have bug in i2c handling.
> >>
> >> You are right about this. Under normal circumstances, if probe is called
> >> then acpi_match_device will not fail. I even tried to remove the
> >> device after probe
> >> but before acpi_match_device, anyhow acpi_match_device was still successful :)
> >>
> >> This is more a matter of code correctness.
> >>
> >> In ak8975_match_acpi_device we have:
> >>
> >> » const struct acpi_device_id *id;
> >>
> >> » id = acpi_match_device(dev->driver->acpi_match_table, dev);
> >> » if (!id)
> >> » » return NULL;
> >> » *chipset = (int)id->driver_data;
> >>
> >> Compiler complains on the fact that chipset might be uninitialized
> >> if this returns NULL, and we shouldn't ignore this warning even this case
> >> will never happen.
> >>
> > Will this fix?
> > data->chipset = AK8975;
> > before
> > ak8975_match_acpi_device(&client->dev, &data->chipset);
> >
>
> Yes, this is done in the original patch:
>
> + *chipset = AK_MAX_TYPE;
Since data memory is not zero alloced, other member of data are anyway
initialized, so adding this also may be better.
>
> .. and fixes the warning.
>
> Daniel.
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
2015-01-19 16:56 ` Pandruvada, Srinivas
(?)
@ 2015-01-23 23:38 ` Hartmut Knaack
2015-01-24 0:17 ` Pandruvada, Srinivas
-1 siblings, 1 reply; 18+ messages in thread
From: Hartmut Knaack @ 2015-01-23 23:38 UTC (permalink / raw)
To: Pandruvada, Srinivas, Baluta, Daniel
Cc: lars@metafoo.de, linux-kernel@vger.kernel.org, jic23@kernel.org,
Purdila, Octavian, linux-iio@vger.kernel.org, Westerberg, Mika,
pmeerw@pmeerw.net, beomho.seo@samsung.com, gwendal@chromium.org
Pandruvada, Srinivas schrieb am 19.01.2015 um 17:56:
> On Mon, 2015-01-19 at 18:49 +0200, Daniel Baluta wrote:
>> On Mon, Jan 19, 2015 at 6:44 PM, Pandruvada, Srinivas
>> <srinivas.pandruvada@intel.com> wrote:
>>> On Mon, 2015-01-19 at 16:40 +0200, Daniel Baluta wrote:
>>>> Hello,
>>>>
>>>> On Sat, Dec 20, 2014 at 11:29 PM, Pandruvada, Srinivas
>>>> <srinivas.pandruvada@intel.com> wrote:
>>>>> +Mika
>>>>>
>>>>> On Sat, 2014-12-20 at 13:26 -0800, Srinivas Pandruvada wrote:
>>>>>> On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
>>>>>>> On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
>>>>>>>> Daniel Baluta schrieb am 18.12.2014 um 18:16:
>>>>>>>>> When using ACPI, if acpi_match_device fails then chipset enum will be
>>>>>>>>> uninitialized and &ak_def_array[chipset] will point to some bad address.
>>>>>>>>>
>>>>>> I am missing something. You are enumerated over i2c device, which was
>>>>>> created from ACPI PNP resource. There is a valid handle or and the
>>>>>> device has an ACPI companion at the least. If this failing, I have to
>>>>>> check the code for acpi i2c.
>>>>>> Can you check why this check failed? We may have bug in i2c handling.
>>>>
>>>> You are right about this. Under normal circumstances, if probe is called
>>>> then acpi_match_device will not fail. I even tried to remove the
>>>> device after probe
>>>> but before acpi_match_device, anyhow acpi_match_device was still successful :)
>>>>
>>>> This is more a matter of code correctness.
>>>>
>>>> In ak8975_match_acpi_device we have:
>>>>
>>>> » const struct acpi_device_id *id;
>>>>
>>>> » id = acpi_match_device(dev->driver->acpi_match_table, dev);
>>>> » if (!id)
>>>> » » return NULL;
>>>> » *chipset = (int)id->driver_data;
>>>>
>>>> Compiler complains on the fact that chipset might be uninitialized
>>>> if this returns NULL, and we shouldn't ignore this warning even this case
>>>> will never happen.
>>>>
>>> Will this fix?
>>> data->chipset = AK8975;
>>> before
>>> ak8975_match_acpi_device(&client->dev, &data->chipset);
>>>
This would fix the compiler warning, but doesn't seem the right solution for
this issue. Quoting the description of acpi_match_device:
"Return a pointer to the first matching ID on success or %NULL on failure."
So, even if it is very unlikely to for it to fail - if it does fail, the
error should be handled as quick as possible. I would favor Daniels solution
to check for a valid assignment of name.
>>
>> Yes, this is done in the original patch:
>>
>> + *chipset = AK_MAX_TYPE;
> Since data memory is not zero alloced, other member of data are anyway
> initialized, so adding this also may be better.
If there did not occur an error condition, it will be assigned a value
before being checked for valid ranges. And if there is an error, probe
should be aborted, anyway. So initializing *chipset doesn't seem to add
any benefit IMHO.
>>
>> .. and fixes the warning.
>>
>> Daniel.
>
> N�����r��y���b�X��ǧv�^�){.n�+����{��*"��^n�r���z�\x1a��h����&��\x1e�G���h�\x03(�階�ݢj"��\x1a�^[m�����z�ޖ���f���h���~�mml==
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
2015-01-23 23:38 ` Hartmut Knaack
@ 2015-01-24 0:17 ` Pandruvada, Srinivas
0 siblings, 0 replies; 18+ messages in thread
From: Pandruvada, Srinivas @ 2015-01-24 0:17 UTC (permalink / raw)
To: knaack.h@gmx.de
Cc: Baluta, Daniel, lars@metafoo.de, linux-kernel@vger.kernel.org,
jic23@kernel.org, Purdila, Octavian, linux-iio@vger.kernel.org,
Westerberg, Mika, pmeerw@pmeerw.net, beomho.seo@samsung.com,
gwendal@chromium.org
T24gU2F0LCAyMDE1LTAxLTI0IGF0IDAwOjM4ICswMTAwLCBIYXJ0bXV0IEtuYWFjayB3cm90ZToN
Cj4gUGFuZHJ1dmFkYSwgU3Jpbml2YXMgc2NocmllYiBhbSAxOS4wMS4yMDE1IHVtIDE3OjU2Og0K
PiA+IE9uIE1vbiwgMjAxNS0wMS0xOSBhdCAxODo0OSArMDIwMCwgRGFuaWVsIEJhbHV0YSB3cm90
ZTogDQo+ID4+IE9uIE1vbiwgSmFuIDE5LCAyMDE1IGF0IDY6NDQgUE0sIFBhbmRydXZhZGEsIF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GQN
Cj4gYW55IGJlbmVmaXQgSU1ITy4NCj4gDQo+ID4+DQo+ID4+IC4uIGFuZCBmaXhlcyB0aGUgd2Fy
bmluZy4NCj4gPj4NCj4gPj4gRGFuaWVsLg0KPiA+IA0KPiA+IE7vv73vv73vv73vv73vv71y77+9
77+9ee+/ve+/ve+/vWLvv71Y77+977+9x6d277+9Xu+/vSneunsubu+/vSvvv73vv73vv73vv717
77+977+9KiLvv73vv71ebu+/vXLvv73vv73vv71677+9Gu+/ve+/vWjvv73vv73vv73vv70m77+9
77+9Hu+/vUfvv73vv73vv71o77+9Ayjvv73pmo7vv73domoi77+977+9Gu+/vRtt77+977+977+9
77+977+9eu+/vd6W77+977+977+9Zu+/ve+/ve+/vWjvv73vv73vv71+77+9bW1sPT0NCj4gPiAN
Cj4gDQoNCg==
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
@ 2015-01-24 0:17 ` Pandruvada, Srinivas
0 siblings, 0 replies; 18+ messages in thread
From: Pandruvada, Srinivas @ 2015-01-24 0:17 UTC (permalink / raw)
To: knaack.h@gmx.de
Cc: Baluta, Daniel, lars@metafoo.de, linux-kernel@vger.kernel.org,
jic23@kernel.org, Purdila, Octavian, linux-iio@vger.kernel.org,
Westerberg, Mika, pmeerw@pmeerw.net, beomho.seo@samsung.com,
gwendal@chromium.org
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3734 bytes --]
On Sat, 2015-01-24 at 00:38 +0100, Hartmut Knaack wrote:
> Pandruvada, Srinivas schrieb am 19.01.2015 um 17:56:
> > On Mon, 2015-01-19 at 18:49 +0200, Daniel Baluta wrote:
> >> On Mon, Jan 19, 2015 at 6:44 PM, Pandruvada, Srinivas
> >> <srinivas.pandruvada@intel.com> wrote:
> >>> On Mon, 2015-01-19 at 16:40 +0200, Daniel Baluta wrote:
> >>>> Hello,
> >>>>
> >>>> On Sat, Dec 20, 2014 at 11:29 PM, Pandruvada, Srinivas
> >>>> <srinivas.pandruvada@intel.com> wrote:
> >>>>> +Mika
> >>>>>
> >>>>> On Sat, 2014-12-20 at 13:26 -0800, Srinivas Pandruvada wrote:
> >>>>>> On Sat, 2014-12-20 at 00:25 +0200, Daniel Baluta wrote:
> >>>>>>> On Sat, Dec 20, 2014 at 12:16 AM, Hartmut Knaack <knaack.h@gmx.de> wrote:
> >>>>>>>> Daniel Baluta schrieb am 18.12.2014 um 18:16:
> >>>>>>>>> When using ACPI, if acpi_match_device fails then chipset enum will be
> >>>>>>>>> uninitialized and &ak_def_array[chipset] will point to some bad address.
> >>>>>>>>>
> >>>>>> I am missing something. You are enumerated over i2c device, which was
> >>>>>> created from ACPI PNP resource. There is a valid handle or and the
> >>>>>> device has an ACPI companion at the least. If this failing, I have to
> >>>>>> check the code for acpi i2c.
> >>>>>> Can you check why this check failed? We may have bug in i2c handling.
> >>>>
> >>>> You are right about this. Under normal circumstances, if probe is called
> >>>> then acpi_match_device will not fail. I even tried to remove the
> >>>> device after probe
> >>>> but before acpi_match_device, anyhow acpi_match_device was still successful :)
> >>>>
> >>>> This is more a matter of code correctness.
> >>>>
> >>>> In ak8975_match_acpi_device we have:
> >>>>
> >>>> » const struct acpi_device_id *id;
> >>>>
> >>>> » id = acpi_match_device(dev->driver->acpi_match_table, dev);
> >>>> » if (!id)
> >>>> » » return NULL;
> >>>> » *chipset = (int)id->driver_data;
> >>>>
> >>>> Compiler complains on the fact that chipset might be uninitialized
> >>>> if this returns NULL, and we shouldn't ignore this warning even this case
> >>>> will never happen.
> >>>>
> >>> Will this fix?
> >>> data->chipset = AK8975;
> >>> before
> >>> ak8975_match_acpi_device(&client->dev, &data->chipset);
> >>>
>
> This would fix the compiler warning, but doesn't seem the right solution for
> this issue. Quoting the description of acpi_match_device:
> "Return a pointer to the first matching ID on success or %NULL on failure."
> So, even if it is very unlikely to for it to fail - if it does fail, the
> error should be handled as quick as possible. I would favor Daniels solution
> to check for a valid assignment of name.
>
This should never fail as the device is enumerated by this. So it
doesn't matter as long as you silent compiler warning.
> >>
> >> Yes, this is done in the original patch:
> >>
> >> + *chipset = AK_MAX_TYPE;
> > Since data memory is not zero alloced, other member of data are anyway
> > initialized, so adding this also may be better.
>
> If there did not occur an error condition, it will be assigned a value
> before being checked for valid ranges. And if there is an error, probe
> should be aborted, anyway. So initializing *chipset doesn't seem to add
> any benefit IMHO.
>
> >>
> >> .. and fixes the warning.
> >>
> >> Daniel.
> >
> > N�����r��y���b�X��ǧv�^�)Þº{.n�+����{��*"��^n�r���z�\x1a��h����&��\x1e�G���h�\x03(�é�ݢj"��\x1a�^[m�����z�Þ���f���h���~�mml==
> >
>
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2015-01-24 0:17 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-18 17:16 [RFC PATCH] iio: ak8975: Make sure chipset is always initialized Daniel Baluta
2014-12-19 22:16 ` Hartmut Knaack
2014-12-19 22:25 ` Daniel Baluta
2014-12-19 22:25 ` Daniel Baluta
2014-12-20 21:26 ` Srinivas Pandruvada
2014-12-20 21:29 ` Pandruvada, Srinivas
2014-12-20 21:29 ` Pandruvada, Srinivas
2014-12-20 21:40 ` Daniel Baluta
2014-12-20 21:40 ` Daniel Baluta
2015-01-19 14:40 ` Daniel Baluta
2015-01-19 16:44 ` Pandruvada, Srinivas
2015-01-19 16:44 ` Pandruvada, Srinivas
2015-01-19 16:49 ` Daniel Baluta
2015-01-19 16:56 ` Pandruvada, Srinivas
2015-01-19 16:56 ` Pandruvada, Srinivas
2015-01-23 23:38 ` Hartmut Knaack
2015-01-24 0:17 ` Pandruvada, Srinivas
2015-01-24 0:17 ` Pandruvada, Srinivas
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.