regulator: anatop-regulator: Remove unneeded check
PATCH 1/2 regulator: anatop-regulator: Remove unneeded check
From: Fabio Estevam <[email protected]>
At the 'anatop_probe_end' error path, the variable 'ret' is known to be non-zero, so there is no need to check it.
--- drivers/regulator/anatop-regulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/regulator/anatop-regulator.c +1 -2
@@ -211,8 +211,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rdev); anatop_probe_end: -if (ret) -kfree (sreg->name); +kfree (sreg->name);return ret; }
Signature · 1 line
1.8.1.2
PATCH 2/2 regulator: anatop-regulator: Remove unneeded variable
From: Fabio Estevam <[email protected]>
There is no need to create a local variable for accessing sreg->name.
Access it directly instead.
--- drivers/regulator/anatop-regulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/regulator/anatop-regulator.c +1 -2
@@ -220,9 +220,8 @@ static int anatop_regulator_remove(struct platform_device *pdev) {struct regulator_dev *rdev =platform_get_drvdata (pdev);struct anatop_regulator *sreg =rdev_get_drvdata (rdev); -const char *name = sreg->name; -kfree (name); +kfree (sreg->name);return 0 ; }
Signature · 1 line
1.8.1.2
Shawn Guo
NAKQuoted 15 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
At the '
anatop_probe_end' error path, the variable 'ret' is known to be non-zero, so there is no need to check it.Signed-off-by Fabio Estevam <[email protected]>--- drivers/regulator/anatop-regulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/regulator/anatop-regulator.c +0
-0
drivers/regulator/anatop-regulator.c static int anatop_regulator_probe(struct platform_device *pdev) · line 214
Quoted 6 lines
drivers/regulator/anatop-regulator.c +1
-2@@ -211,8 +211,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rdev); anatop_probe_end: -if (ret) -kfree (sreg->name); +kfree (sreg->name);
NAK
With the change, a successful probe will end up with calling this kfree() as well.
Shawn
Quoted 6 lines
drivers/regulator/anatop-regulator.c +0
-0return ret; }Signature · 1 line
1.8.1.2
Quoted 25 lines · Shawn Guo
Quoted 15 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
At the '
anatop_probe_end' error path, the variable 'ret' is known to be non-zero, so there is no need to check it.Signed-off-by Fabio Estevam <[email protected]>--- drivers/regulator/anatop-regulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/regulator/anatop-regulator.c +0
-0drivers/regulator/anatop-regulator.c static int anatop_regulator_probe(struct platform_device *pdev) · line 214
Quoted 6 lines
drivers/regulator/anatop-regulator.c +1
-2@@ -211,8 +211,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rdev); anatop_probe_end: -if (ret) -kfree (sreg->name); +kfree (sreg->name);NAK
Quoted 2 lines
With the change, a successful probe will end up with calling this
kfree()as well.
I see. Then we can do this instead, so that the successful probe and the error path are clearer:
drivers/regulator/anatop-regulator.c +3 -2
@@ -210,9 +210,10 @@ static int anatop_regulator_probe(struct platform_device *pplatform_set_drvdata (pdev, rdev); +return 0 ; + anatop_probe_end: -if (ret) -kfree (sreg->name); +kfree (sreg->name);return ret; }
Regards,
Fabio Estevam
Mark Brown
maintainerQuoted 2 lines · Fabio Estevam
I see. Then we can do this instead, so that the successful probe and the error path are clearer:
Yes, that's going to cause fewer surprises.