* [PATCH 2/2] sound/soc/fsl/mpc8610_hpcd.c: add missing of_node_put
@ 2011-08-20 7:02 Julia Lawall
2011-08-22 22:30 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2011-08-20 7:02 UTC (permalink / raw)
To: Timur Tabi
Cc: alsa-devel, Takashi Iwai, devicetree-discuss, Mark Brown,
kernel-janitors, linux-kernel, Jaroslav Kysela, linuxppc-dev,
Liam Girdwood
From: Julia Lawall <julia@diku.dk>
The first change is to add an of_node_put, since codec_np has previously
been allocated. The rest of the patch reorganizes the error handling code
so the only code executed is that which is needed.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
identifier x;
expression E1!=0,E2,E3,E4;
statement S;
iterator I;
@@
(
if (...) { ... when != of_node_put(x)
when != x = E3
when != E3 = x
* return ...;
}
... when != x = E2
when != I(...,x,...) S
if (...) { ... when != x = E4
of_node_put(x); ... return ...; }
)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
sound/soc/fsl/mpc8610_hpcd.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c
index a192979..358f0ba 100644
--- a/sound/soc/fsl/mpc8610_hpcd.c
+++ b/sound/soc/fsl/mpc8610_hpcd.c
@@ -345,8 +345,10 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
}
machine_data = kzalloc(sizeof(struct mpc8610_hpcd_data), GFP_KERNEL);
- if (!machine_data)
- return -ENOMEM;
+ if (!machine_data) {
+ ret = -ENOMEM;
+ goto error_alloc;
+ }
machine_data->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
machine_data->dai[0].ops = &mpc8610_hpcd_ops;
@@ -494,7 +496,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
ret = platform_device_add(sound_device);
if (ret) {
dev_err(&pdev->dev, "platform device add failed\n");
- goto error;
+ goto error_sound;
}
dev_set_drvdata(&pdev->dev, sound_device);
@@ -502,14 +504,12 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
return 0;
+error_sound:
+ platform_device_unregister(sound_device);
error:
- of_node_put(codec_np);
-
- if (sound_device)
- platform_device_unregister(sound_device);
-
kfree(machine_data);
-
+error_alloc:
+ of_node_put(codec_np);
return ret;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] sound/soc/fsl/mpc8610_hpcd.c: add missing of_node_put
2011-08-20 7:02 [PATCH 2/2] sound/soc/fsl/mpc8610_hpcd.c: add missing of_node_put Julia Lawall
@ 2011-08-22 22:30 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2011-08-22 22:30 UTC (permalink / raw)
To: Julia Lawall
Cc: alsa-devel, Liam Girdwood, Takashi Iwai, devicetree-discuss,
kernel-janitors, linux-kernel, Jaroslav Kysela, linuxppc-dev,
Timur Tabi
On Sat, Aug 20, 2011 at 09:02:01AM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
>
> The first change is to add an of_node_put, since codec_np has previously
> been allocated. The rest of the patch reorganizes the error handling code
> so the only code executed is that which is needed.
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-08-22 22:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-20 7:02 [PATCH 2/2] sound/soc/fsl/mpc8610_hpcd.c: add missing of_node_put Julia Lawall
2011-08-22 22:30 ` Mark Brown
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).