Skip to contentSkip to conversation

driver core: platform: remove misleading err_alloc label

PATCH In review Johannes Berg 2 participants 2 messages Mar 1, 2019 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver core: platform: remove misleading err_alloc label

From: Johannes Berg <[email protected]>

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.

---
 drivers/base/platform.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/base/platform.c +1 -3
index 1c958eb33ef4..75fccb7dc908 100644
@@ -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);
 	}
Signature · 1 line
2.17.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Johannes Berg

From: Johannes Berg <[email protected]>

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.

Quoted 29 lines
---
 drivers/base/platform.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/base/platform.c +1 -4
index 1c958eb33ef4..75fccb7dc908 100644
@@ -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