public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] ACPI / LPSS: set an error code
@ 2015-07-03  8:56 Dan Carpenter
  2015-07-06 22:56 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2015-07-03  8:56 UTC (permalink / raw)
  To: Rafael J. Wysocki, Heikki Krogerus; +Cc: Len Brown, linux-acpi, kernel-janitors

We should return -ENOMEM if ioremap() fails.

Fixes: 4483d59e29fe ('ACPI / LPSS: check the result of ioremap()')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 569ee09..10bf5c7 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -352,8 +352,10 @@ 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);
-			if (!pdata->mmio_base)
+			if (!pdata->mmio_base) {
+				ret = -ENOMEM;
 				goto err_out;
+			}
 			break;
 		}
 

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

* Re: [patch] ACPI / LPSS: set an error code
  2015-07-03  8:56 [patch] ACPI / LPSS: set an error code Dan Carpenter
@ 2015-07-06 22:56 ` Rafael J. Wysocki
  2015-07-07  7:50   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2015-07-06 22:56 UTC (permalink / raw)
  To: Dan Carpenter, Heikki Krogerus; +Cc: Len Brown, linux-acpi, kernel-janitors

On Friday, July 03, 2015 11:56:53 AM Dan Carpenter wrote:
> We should return -ENOMEM if ioremap() fails.
> 
> Fixes: 4483d59e29fe ('ACPI / LPSS: check the result of ioremap()')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> index 569ee09..10bf5c7 100644
> --- a/drivers/acpi/acpi_lpss.c
> +++ b/drivers/acpi/acpi_lpss.c
> @@ -352,8 +352,10 @@ 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);
> -			if (!pdata->mmio_base)
> +			if (!pdata->mmio_base) {
> +				ret = -ENOMEM;
>  				goto err_out;
> +			}
>  			break;
>  		}

This looks insufficient to my eyes, as we leak memory here too.

What about the following instead?

---
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Subject: ACPI / LPSS: Fix up acpi_lpss_create_device()

Fix a return value (which should be a negative error code) and a
memory leak (the list allocated by acpi_dev_get_resources() needs
to be freed on ioremap() errors too) in acpi_lpss_create_device()
introduced by commit 4483d59e29fe 'ACPI / LPSS: check the result
of ioremap()'.

Fixes: 4483d59e29fe 'ACPI / LPSS: check the result of ioremap()'
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: 4.0+ <stable@vger.kernel.org> # 4.0+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpi_lpss.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/acpi/acpi_lpss.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_lpss.c
+++ linux-pm/drivers/acpi/acpi_lpss.c
@@ -352,13 +352,16 @@ static int acpi_lpss_create_device(struc
 				pdata->mmio_size = resource_size(rentry->res);
 			pdata->mmio_base = ioremap(rentry->res->start,
 						   pdata->mmio_size);
-			if (!pdata->mmio_base)
-				goto err_out;
 			break;
 		}
 
 	acpi_dev_free_resource_list(&resource_list);
 
+	if (!pdata->mmio_base) {
+		ret = -ENOMEM;
+		goto err_out;
+	}
+
 	pdata->dev_desc = dev_desc;
 
 	if (dev_desc->setup)


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

* Re: [patch] ACPI / LPSS: set an error code
  2015-07-06 22:56 ` Rafael J. Wysocki
@ 2015-07-07  7:50   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2015-07-07  7:50 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Heikki Krogerus, Len Brown, linux-acpi, kernel-janitors

On Tue, Jul 07, 2015 at 12:56:21AM +0200, Rafael J. Wysocki wrote:
> This looks insufficient to my eyes, as we leak memory here too.
> 
> What about the following instead?

Yeah.  You are, of course, correct.

regards,
dan carpenter



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

end of thread, other threads:[~2015-07-07  7:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-03  8:56 [patch] ACPI / LPSS: set an error code Dan Carpenter
2015-07-06 22:56 ` Rafael J. Wysocki
2015-07-07  7:50   ` Dan Carpenter

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