Skip to content

Commit 4a4c848

Browse files
Yang Yingliangtiwai
authored andcommitted
ALSA: aoa: i2sbus: fix possible memory leak in i2sbus_add_dev()
dev_set_name() in soundbus_add_one() allocates memory for name, it need be freed when of_device_register() fails, call soundbus_dev_put() to give up the reference that hold in device_initialize(), so that it can be freed in kobject_cleanup() when the refcount hit to 0. And other resources are also freed in i2sbus_release_dev(), so it can return 0 directly. Fixes: f3d9478 ("[ALSA] snd-aoa: add snd-aoa") Signed-off-by: Yang Yingliang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent f850a2b commit 4a4c848

File tree

1 file changed

+4
-0
lines changed
  • sound/aoa/soundbus/i2sbus

1 file changed

+4
-0
lines changed

sound/aoa/soundbus/i2sbus/core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ static int i2sbus_add_dev(struct macio_dev *macio,
302302

303303
if (soundbus_add_one(&dev->sound)) {
304304
printk(KERN_DEBUG "i2sbus: device registration error!\n");
305+
if (dev->sound.ofdev.dev.kobj.state_initialized) {
306+
soundbus_dev_put(&dev->sound);
307+
return 0;
308+
}
305309
goto err;
306310
}
307311

0 commit comments

Comments
 (0)