Linux ACPI
 help / color / mirror / Atom feed
* [PATCH] ACPI / LPSS: don't crash if a device has no MMIO resources
@ 2013-09-02 10:30 Mika Westerberg
  2013-09-02 12:25 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Mika Westerberg @ 2013-09-02 10:30 UTC (permalink / raw)
  To: linux-acpi; +Cc: Rafael J. Wysocki, Imre Kaloz, Mika Westerberg, linux-kernel

Intel LPSS devices that are enumerated from ACPI have both MMIO and IRQ
resources returned in their _CRS method. However, Apple Macbook Air with
Haswell has LPSS devices enumerated from PCI bus instead and _CRS method
returns only an interrupt number (but the device has _HID set that causes
the scan handler to match it).

The current ACPI / LPSS code sets pdata->dev_desc only when MMIO resource
is found for the device and in case of Macbook Air it is never found. That
leads to a NULL pointer dereference in register_device_clock().

Correct this by always setting the pdata->dev_desc.

Reported-and-tested-by: Imre Kaloz <kaloz@openwrt.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: stable@vger.kernel.org # 3.10+
---
 drivers/acpi/acpi_lpss.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 6a38218..fb78bb9 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -257,12 +257,13 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
 				pdata->mmio_size = resource_size(&rentry->res);
 			pdata->mmio_base = ioremap(rentry->res.start,
 						   pdata->mmio_size);
-			pdata->dev_desc = dev_desc;
 			break;
 		}
 
 	acpi_dev_free_resource_list(&resource_list);
 
+	pdata->dev_desc = dev_desc;
+
 	if (dev_desc->clk_required) {
 		ret = register_device_clock(adev, pdata);
 		if (ret) {
-- 
1.8.4.rc3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ACPI / LPSS: don't crash if a device has no MMIO resources
  2013-09-02 10:30 [PATCH] ACPI / LPSS: don't crash if a device has no MMIO resources Mika Westerberg
@ 2013-09-02 12:25 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2013-09-02 12:25 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: linux-acpi, Rafael J. Wysocki, Imre Kaloz, linux-kernel

On Monday, September 02, 2013 01:30:25 PM Mika Westerberg wrote:
> Intel LPSS devices that are enumerated from ACPI have both MMIO and IRQ
> resources returned in their _CRS method. However, Apple Macbook Air with
> Haswell has LPSS devices enumerated from PCI bus instead and _CRS method
> returns only an interrupt number (but the device has _HID set that causes
> the scan handler to match it).
> 
> The current ACPI / LPSS code sets pdata->dev_desc only when MMIO resource
> is found for the device and in case of Macbook Air it is never found. That
> leads to a NULL pointer dereference in register_device_clock().
> 
> Correct this by always setting the pdata->dev_desc.
> 
> Reported-and-tested-by: Imre Kaloz <kaloz@openwrt.org>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: stable@vger.kernel.org # 3.10+

Queued up for 3.12, thanks for taking care of this Mika!

> ---
>  drivers/acpi/acpi_lpss.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> index 6a38218..fb78bb9 100644
> --- a/drivers/acpi/acpi_lpss.c
> +++ b/drivers/acpi/acpi_lpss.c
> @@ -257,12 +257,13 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
>  				pdata->mmio_size = resource_size(&rentry->res);
>  			pdata->mmio_base = ioremap(rentry->res.start,
>  						   pdata->mmio_size);
> -			pdata->dev_desc = dev_desc;
>  			break;
>  		}
>  
>  	acpi_dev_free_resource_list(&resource_list);
>  
> +	pdata->dev_desc = dev_desc;
> +
>  	if (dev_desc->clk_required) {
>  		ret = register_device_clock(adev, pdata);
>  		if (ret) {
> 
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-09-02 12:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-02 10:30 [PATCH] ACPI / LPSS: don't crash if a device has no MMIO resources Mika Westerberg
2013-09-02 12:25 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox