Skip to content

Commit

Permalink
powerpc/ps3: Fix memory leak in device init
Browse files Browse the repository at this point in the history
Free dynamically allocated device data structures when device registration
fails.  This fixes memory leakage when the registration fails.

Signed-off-by: Masakazu Mokuno <mokuno@sm.sony.co.jp>
Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Masakazu Mokuno authored and Paul Mackerras committed Nov 5, 2008
1 parent 3cc6987 commit d4ad304
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions arch/powerpc/platforms/ps3/device-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,17 @@ static int __init ps3_setup_vuart_device(enum ps3_match_id match_id,

result = ps3_system_bus_device_register(&p->dev);

if (result)
if (result) {
pr_debug("%s:%d ps3_system_bus_device_register failed\n",
__func__, __LINE__);

goto fail_device_register;
}
pr_debug(" <- %s:%d\n", __func__, __LINE__);
return 0;

fail_device_register:
kfree(p);
pr_debug(" <- %s:%d fail\n", __func__, __LINE__);
return result;
}

Expand Down Expand Up @@ -463,11 +469,17 @@ static int __init ps3_register_sound_devices(void)

result = ps3_system_bus_device_register(&p->dev);

if (result)
if (result) {
pr_debug("%s:%d ps3_system_bus_device_register failed\n",
__func__, __LINE__);

goto fail_device_register;
}
pr_debug(" <- %s:%d\n", __func__, __LINE__);
return 0;

fail_device_register:
kfree(p);
pr_debug(" <- %s:%d failed\n", __func__, __LINE__);
return result;
}

Expand All @@ -491,11 +503,18 @@ static int __init ps3_register_graphics_devices(void)

result = ps3_system_bus_device_register(&p->dev);

if (result)
if (result) {
pr_debug("%s:%d ps3_system_bus_device_register failed\n",
__func__, __LINE__);
goto fail_device_register;
}

pr_debug(" <- %s:%d\n", __func__, __LINE__);
return 0;

fail_device_register:
kfree(p);
pr_debug(" <- %s:%d failed\n", __func__, __LINE__);
return result;
}

Expand Down

0 comments on commit d4ad304

Please sign in to comment.