1 From d4ad304841a9790d4fa35e51d6aa9baeba631559 Mon Sep 17 00:00:00 2001
2 From: Masakazu Mokuno <mokuno@sm.sony.co.jp>
3 Date: Thu, 30 Oct 2008 08:17:18 +0000
4 Subject: [PATCH] powerpc/ps3: Fix memory leak in device init
6 Free dynamically allocated device data structures when device registration
7 fails. This fixes memory leakage when the registration fails.
9 Signed-off-by: Masakazu Mokuno <mokuno@sm.sony.co.jp>
10 Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
11 Signed-off-by: Paul Mackerras <paulus@samba.org>
13 arch/powerpc/platforms/ps3/device-init.c | 29 ++++++++++++++++++++++++-----
14 1 files changed, 24 insertions(+), 5 deletions(-)
16 diff --git a/arch/powerpc/platforms/ps3/device-init.c b/arch/powerpc/platforms/ps3/device-init.c
17 index ffdd8e9..43816da 100644
18 --- a/arch/powerpc/platforms/ps3/device-init.c
19 +++ b/arch/powerpc/platforms/ps3/device-init.c
20 @@ -314,11 +314,17 @@ static int __init ps3_setup_vuart_device(enum ps3_match_id match_id,
22 result = ps3_system_bus_device_register(&p->dev);
26 pr_debug("%s:%d ps3_system_bus_device_register failed\n",
29 + goto fail_device_register;
31 pr_debug(" <- %s:%d\n", __func__, __LINE__);
34 +fail_device_register:
36 + pr_debug(" <- %s:%d fail\n", __func__, __LINE__);
40 @@ -463,11 +469,17 @@ static int __init ps3_register_sound_devices(void)
42 result = ps3_system_bus_device_register(&p->dev);
46 pr_debug("%s:%d ps3_system_bus_device_register failed\n",
49 + goto fail_device_register;
51 pr_debug(" <- %s:%d\n", __func__, __LINE__);
54 +fail_device_register:
56 + pr_debug(" <- %s:%d failed\n", __func__, __LINE__);
60 @@ -491,11 +503,18 @@ static int __init ps3_register_graphics_devices(void)
62 result = ps3_system_bus_device_register(&p->dev);
66 pr_debug("%s:%d ps3_system_bus_device_register failed\n",
68 + goto fail_device_register;
71 pr_debug(" <- %s:%d\n", __func__, __LINE__);
74 +fail_device_register:
76 + pr_debug(" <- %s:%d failed\n", __func__, __LINE__);