linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] driver core: platform: remove misleading err_alloc label
@ 2019-03-01 12:24 Johannes Berg
  2019-03-01 13:05 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Berg @ 2019-03-01 12:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Rafael J. Wysocki, linux-kernel, Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

In platform_device_register_full() the err_alloc label is
misleading, we only ever jump to it if the pdev is NULL,
but it then proceeds to free it, which is a no-op.

Remove the label and simply exit the function immediately.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 drivers/base/platform.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 1c958eb33ef4..75fccb7dc908 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -508,7 +508,7 @@ struct platform_device *platform_device_register_full(
 
 	pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id);
 	if (!pdev)
-		goto err_alloc;
+		return ERR_PTR(-ENOMEM);
 
 	pdev->dev.parent = pdevinfo->parent;
 	pdev->dev.fwnode = pdevinfo->fwnode;
@@ -553,8 +553,6 @@ struct platform_device *platform_device_register_full(
 err:
 		ACPI_COMPANION_SET(&pdev->dev, NULL);
 		kfree(pdev->dev.dma_mask);
-
-err_alloc:
 		platform_device_put(pdev);
 		return ERR_PTR(ret);
 	}
-- 
2.17.2


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

* Re: [PATCH] driver core: platform: remove misleading err_alloc label
  2019-03-01 12:24 [PATCH] driver core: platform: remove misleading err_alloc label Johannes Berg
@ 2019-03-01 13:05 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2019-03-01 13:05 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linux Kernel Mailing List,
	Johannes Berg

On Fri, Mar 1, 2019 at 2:01 PM Johannes Berg <johannes@sipsolutions.net> wrote:
>
> From: Johannes Berg <johannes.berg@intel.com>
>
> In platform_device_register_full() the err_alloc label is
> misleading, we only ever jump to it if the pdev is NULL,
> but it then proceeds to free it, which is a no-op.
>
> Remove the label and simply exit the function immediately.
>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  drivers/base/platform.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 1c958eb33ef4..75fccb7dc908 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -508,7 +508,7 @@ struct platform_device *platform_device_register_full(
>
>         pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id);
>         if (!pdev)
> -               goto err_alloc;
> +               return ERR_PTR(-ENOMEM);
>
>         pdev->dev.parent = pdevinfo->parent;
>         pdev->dev.fwnode = pdevinfo->fwnode;
> @@ -553,8 +553,6 @@ struct platform_device *platform_device_register_full(
>  err:
>                 ACPI_COMPANION_SET(&pdev->dev, NULL);
>                 kfree(pdev->dev.dma_mask);
> -
> -err_alloc:
>                 platform_device_put(pdev);
>                 return ERR_PTR(ret);
>         }
> --
> 2.17.2
>

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

end of thread, other threads:[~2019-03-01 13:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-01 12:24 [PATCH] driver core: platform: remove misleading err_alloc label Johannes Berg
2019-03-01 13:05 ` 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;
as well as URLs for NNTP newsgroup(s).