* [v2,2/6] ACPI / bus: Do not traverse through non-existed device table
@ 2018-02-01 20:20 Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2018-02-01 20:20 UTC (permalink / raw)
To: dmaengine, Rafael J . Wysocki, linux-acpi
Cc: Andy Shevchenko, Sinan Kaya, Sakari Ailus, Vinod Koul
When __acpi_match_device() is called it would be possible to have
ACPI ID table a MULL pointer. To avoid potential dereference,
check for this before traverse.
While here, remove redundant 'else'.
Fixes: 80212a162329 ("ACPI / bus: Introduce acpi_get_match_data() function")
Cc: Sinan Kaya <okaya@codeaurora.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: new patch
drivers/acpi/bus.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index a87a97bf75f8..f3a7c29e9190 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -745,11 +745,13 @@ static const struct acpi_device_id *__acpi_match_device(
list_for_each_entry(hwid, &device->pnp.ids, list) {
/* First, check the ACPI/PNP IDs provided by the caller. */
- for (id = ids; id->id[0] || id->cls; id++) {
- if (id->id[0] && !strcmp((char *) id->id, hwid->id))
- return id;
- else if (id->cls && __acpi_match_device_cls(id, hwid))
- return id;
+ if (ids) {
+ for (id = ids; id->id[0] || id->cls; id++) {
+ if (id->id[0] && !strcmp((char *)id->id, hwid->id))
+ return id;
+ if (id->cls && __acpi_match_device_cls(id, hwid))
+ return id;
+ }
}
/*
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [v2,2/6] ACPI / bus: Do not traverse through non-existed device table
@ 2018-02-01 20:32 Sinan Kaya
0 siblings, 0 replies; 7+ messages in thread
From: Sinan Kaya @ 2018-02-01 20:32 UTC (permalink / raw)
To: Andy Shevchenko, dmaengine, Rafael J . Wysocki, linux-acpi
Cc: Sakari Ailus, Vinod Koul
On 2/1/2018 3:20 PM, Andy Shevchenko wrote:
> When __acpi_match_device() is called it would be possible to have
> ACPI ID table a MULL pointer. To avoid potential dereference,
NULL
> check for this before traverse.
>
> While here, remove redundant 'else'.
>
> Fixes: 80212a162329 ("ACPI / bus: Introduce acpi_get_match_data() function")
> Cc: Sinan Kaya <okaya@codeaurora.org>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: Vinod Koul <vinod.koul@intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v2: new patch
> drivers/acpi/bus.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index a87a97bf75f8..f3a7c29e9190 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -745,11 +745,13 @@ static const struct acpi_device_id *__acpi_match_device(
>
> list_for_each_entry(hwid, &device->pnp.ids, list) {
> /* First, check the ACPI/PNP IDs provided by the caller. */
> - for (id = ids; id->id[0] || id->cls; id++) {
> - if (id->id[0] && !strcmp((char *) id->id, hwid->id))
> - return id;
> - else if (id->cls && __acpi_match_device_cls(id, hwid))
> - return id;
> + if (ids) {
> + for (id = ids; id->id[0] || id->cls; id++) {
> + if (id->id[0] && !strcmp((char *)id->id, hwid->id))
> + return id;
> + if (id->cls && __acpi_match_device_cls(id, hwid))
> + return id;
> + }
> }
>
> /*
>
Why not bail out here immediately if ids is null?
__acpi_match_device()
{
/*
* If the device is not present, it is unnecessary to load device
* driver for it.
*/
if (!device || !device->status.present)
return NULL;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [v2,2/6] ACPI / bus: Do not traverse through non-existed device table
@ 2018-02-01 20:40 Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2018-02-01 20:40 UTC (permalink / raw)
To: Sinan Kaya, dmaengine, Rafael J . Wysocki, linux-acpi
Cc: Sakari Ailus, Vinod Koul
On Thu, 2018-02-01 at 15:32 -0500, Sinan Kaya wrote:
> On 2/1/2018 3:20 PM, Andy Shevchenko wrote:
> > When __acpi_match_device() is called it would be possible to have
> > ACPI ID table a MULL pointer. To avoid potential dereference,
>
> NULL
Thanks, will fix later.
> Why not bail out here immediately if ids is null?
Because of the code which wasn't in context of this patch.
See also patch 1 in the series.
It's about how acpi_driver_match_device() uses it.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [v2,2/6] ACPI / bus: Do not traverse through non-existed device table
@ 2018-02-01 20:45 Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2018-02-01 20:45 UTC (permalink / raw)
To: Sinan Kaya, dmaengine, Rafael J . Wysocki, linux-acpi
Cc: Sakari Ailus, Vinod Koul
On Thu, 2018-02-01 at 22:40 +0200, Andy Shevchenko wrote:
> On Thu, 2018-02-01 at 15:32 -0500, Sinan Kaya wrote:
> > On 2/1/2018 3:20 PM, Andy Shevchenko wrote:
> > > When __acpi_match_device() is called it would be possible to have
> > > ACPI ID table a MULL pointer. To avoid potential dereference,
> >
> > NULL
>
> Thanks, will fix later.
>
> > Why not bail out here immediately if ids is null?
>
> Because of the code which wasn't in context of this patch.
>
> See also patch 1 in the series.
>
> It's about how acpi_driver_match_device() uses it.
Btw, it makes device_get_match_data() to work properly on PRP0001 kind
of devices.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [v2,2/6] ACPI / bus: Do not traverse through non-existed device table
@ 2018-02-04 7:18 Rafael J. Wysocki
0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2018-02-04 7:18 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sinan Kaya, dmaengine, Rafael J . Wysocki, ACPI Devel Maling List,
Sakari Ailus, Vinod Koul
On Thu, Feb 1, 2018 at 9:45 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Thu, 2018-02-01 at 22:40 +0200, Andy Shevchenko wrote:
>> On Thu, 2018-02-01 at 15:32 -0500, Sinan Kaya wrote:
>> > On 2/1/2018 3:20 PM, Andy Shevchenko wrote:
>> > > When __acpi_match_device() is called it would be possible to have
>> > > ACPI ID table a MULL pointer. To avoid potential dereference,
>> >
>> > NULL
>>
>> Thanks, will fix later.
>>
>> > Why not bail out here immediately if ids is null?
>>
>> Because of the code which wasn't in context of this patch.
>>
>> See also patch 1 in the series.
>>
>> It's about how acpi_driver_match_device() uses it.
>
> Btw, it makes device_get_match_data() to work properly on PRP0001 kind
> of devices.
Maybe combine this one with the [1/6] then, it would make it somewhat
easier to follow what's going on.
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* [v2,2/6] ACPI / bus: Do not traverse through non-existed device table
@ 2018-02-05 15:56 Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2018-02-05 15:56 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Sinan Kaya, dmaengine, Rafael J . Wysocki, ACPI Devel Maling List,
Sakari Ailus, Vinod Koul
On Sun, 2018-02-04 at 08:18 +0100, Rafael J. Wysocki wrote:
> On Thu, Feb 1, 2018 at 9:45 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Thu, 2018-02-01 at 22:40 +0200, Andy Shevchenko wrote:
> > > On Thu, 2018-02-01 at 15:32 -0500, Sinan Kaya wrote:
> > > > On 2/1/2018 3:20 PM, Andy Shevchenko wrote:
> > > > > When __acpi_match_device() is called it would be possible to
> > > > > have
> > > > > ACPI ID table a MULL pointer. To avoid potential dereference,
> > > >
> > > > NULL
> > >
> > > Thanks, will fix later.
> > >
> > > > Why not bail out here immediately if ids is null?
> > >
> > > Because of the code which wasn't in context of this patch.
> > >
> > > See also patch 1 in the series.
> > >
> > > It's about how acpi_driver_match_device() uses it.
> >
> > Btw, it makes device_get_match_data() to work properly on PRP0001
> > kind
> > of devices.
>
> Maybe combine this one with the [1/6] then, it would make it somewhat
> easier to follow what's going on.
Sure, I will fold in.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [v2,2/6] ACPI / bus: Do not traverse through non-existed device table
@ 2018-02-05 15:59 Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2018-02-05 15:59 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Sinan Kaya, dmaengine, Rafael J . Wysocki, ACPI Devel Maling List,
Sakari Ailus, Vinod Koul
On Mon, 2018-02-05 at 17:56 +0200, Andy Shevchenko wrote:
> On Sun, 2018-02-04 at 08:18 +0100, Rafael J. Wysocki wrote:
> > On Thu, Feb 1, 2018 at 9:45 PM, Andy Shevchenko
> >
> > Maybe combine this one with the [1/6] then, it would make it
> > somewhat
> > easier to follow what's going on.
>
> Sure, I will fold in.
Ah, wait, they have different Fixes tag. One goes deeply down in the
history.
So, I can instead put more explanations in patch 1.
Would it work?
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-02-05 15:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-05 15:59 [v2,2/6] ACPI / bus: Do not traverse through non-existed device table Andy Shevchenko
-- strict thread matches above, loose matches on Subject: below --
2018-02-05 15:56 Andy Shevchenko
2018-02-04 7:18 Rafael J. Wysocki
2018-02-01 20:45 Andy Shevchenko
2018-02-01 20:40 Andy Shevchenko
2018-02-01 20:32 Sinan Kaya
2018-02-01 20:20 Andy Shevchenko
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).