Skip to contentSkip to conversation

leds-88pm860x: use the goto label at data->port

PATCH In review Devendra Naga 2 participants 4 messages Jul 2, 2012 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds-88pm860x: use the goto label at data->port

at the goto lable out: we are doing free of the led data, and returning ret. the same we are doing at the data->port < 0 case, so use the goto end and assign ret to -EINVAL. this will make the common err path for the data->port and led_classdev_register functions.

---
 drivers/leds/leds-88pm860x.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-88pm860x.c +2 -2
index 5b61aaf..538aaa3 100644
@@ -220,8 +220,8 @@ static int pm860x_led_probe(struct platform_device *pdev)
 	data->port = pdata->flags;
 	if (data->port < 0) {
 		dev_err(&pdev->dev, "check device failed\n");
-		kfree(data);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	data->current_brightness = 0;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 5 lines · Devendra Naga

at the goto lable out: we are doing free of the led data, and returning ret. the same we are doing at the data->port < 0 case, so use the goto end and assign ret to -EINVAL. this will make the common err path for the data->port and led_classdev_register functions.

This patch is not wrong, but it'd better we replace kzalloc/kfree to devm_kzalloc. So we don't care about kfree anymore.
Are interested in doing that?

Thanks,
-Bryan

Quoted 27 lines
---
 drivers/leds/leds-88pm860x.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-88pm860x.c +2 -3
index 5b61aaf..538aaa3 100644
@@ -220,8 +220,8 @@ static int pm860x_led_probe(struct platform_device *pdev)
        data->port = pdata->flags;
        if (data->port < 0) {
                dev_err(&pdev->dev, "check device failed\n");
-               kfree(data);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto out;
        }
 
        data->current_brightness = 0;
--

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 4 lines
Bryan Wu <[email protected]>
Kernel Developer    +86.186-168-78255 Mobile
Canonical Ltd.      www.canonical.com
Ubuntu - Linux for human beings | www.ubuntu.com
#2 lore raw
Quoted 11 lines · Bryan Wu
Quoted 5 lines · Devendra Naga

at the goto lable out: we are doing free of the led data, and returning ret. the same we are doing at the data->port < 0 case, so use the goto end and assign ret to -EINVAL. this will make the common err path for the data->port and led_classdev_register functions.

This patch is not wrong, but it'd better we replace kzalloc/kfree to devm_kzalloc. So we don't care about kfree anymore.
Are interested in doing that?

I have a doubt,

I think the dev pointer is chip->dev for using devm_* ?

please suggest me if i am wrong.

Quoted 26 lines

Thanks,
-Bryan

Quoted 23 lines
---
 drivers/leds/leds-88pm860x.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-88pm860x.c +2 -3
index 5b61aaf..538aaa3 100644
@@ -220,8 +220,8 @@ static int pm860x_led_probe(struct platform_device *pdev)
        data->port = pdata->flags;
        if (data->port < 0) {
                dev_err(&pdev->dev, "check device failed\n");
-               kfree(data);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto out;
        }
 
        data->current_brightness = 0;
--

1.7.9.5

Quoted 12 lines
Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Bryan Wu <[email protected]>
Kernel Developer +86.186-168-78255 Mobile
Canonical Ltd. www.canonical.com
Ubuntu - Linux for human beings | www.ubuntu.com

Thanks,
Devendra.

#3 lore raw
Quoted 8 lines · devendra.aaru
Quoted 7 lines · Bryan Wu
Quoted 5 lines · Devendra Naga

at the goto lable out: we are doing free of the led data, and returning ret. the same we are doing at the data->port < 0 case, so use the goto end and assign ret to -EINVAL. this will make the common err path for the data->port and led_classdev_register functions.

Quoted 8 lines
Quoted 4 lines

This patch is not wrong, but it'd better we replace kzalloc/kfree to devm_kzalloc. So we don't care about kfree anymore.
Are interested in doing that?

I have a doubt,

I think the dev pointer is chip->dev for using devm_* ?

        data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_led), GFP_KERNEL);

You can simply just use pdev->dev, right?

-Bryan

Quoted 46 lines

please suggest me if i am wrong.

Quoted 26 lines

Thanks,
-Bryan

Quoted 23 lines
---
 drivers/leds/leds-88pm860x.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-88pm860x.c +2 -3
index 5b61aaf..538aaa3 100644
@@ -220,8 +220,8 @@ static int pm860x_led_probe(struct platform_device *pdev)
        data->port = pdata->flags;
        if (data->port < 0) {
                dev_err(&pdev->dev, "check device failed\n");
-               kfree(data);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto out;
        }
 
        data->current_brightness = 0;
--

1.7.9.5

Quoted 12 lines
Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Bryan Wu <[email protected]>
Kernel Developer +86.186-168-78255 Mobile
Canonical Ltd. www.canonical.com
Ubuntu - Linux for human beings | www.ubuntu.com

Thanks,
Devendra.
--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 4 lines
Bryan Wu <[email protected]>
Kernel Developer    +86.186-168-78255 Mobile
Canonical Ltd.      www.canonical.com
Ubuntu - Linux for human beings | www.ubuntu.com