* [PATCH] sound/oss/dmasound: unregister OSS devices on init failure
@ 2026-11-27 4:55 Haoxiang Li
2026-11-27 17:34 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-11-27 4:55 UTC (permalink / raw)
To: perex, tiwai, cassiogabrielcontato, tim.bird; +Cc: linux-sound, Haoxiang Li
dmasound_init() registers dsp, special sound and mixer device
but never unregisters if something fails. Unregister the devices
in the error handling path so a failed initialization leaves
no stale OSS registrations. Also fix some code styles.
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
sound/oss/dmasound/dmasound_core.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
index e80f730d0803..15e4682e6cf8 100644
--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -1377,18 +1377,29 @@ int dmasound_init(void)
/* Set up sound queue, /dev/audio and /dev/dsp. */
/* Set default settings. */
- if ((res = sq_init()) < 0)
- return res ;
+ res = sq_init();
+ if (res < 0)
+ return res;
/* Set up /dev/sndstat. */
- if ((res = state_init()) < 0)
- return res ;
+ res = state_init();
+ if (res < 0) {
+ if (sq_unit >= 0)
+ unregister_sound_dsp(sq_unit);
+ return res;
+ }
/* Set up /dev/mixer. */
mixer_init();
if (!dmasound.mach.irqinit()) {
printk(KERN_ERR "DMA sound driver: Interrupt initialization failed\n");
+ if (mixer_unit >= 0)
+ unregister_sound_mixer(mixer_unit);
+ if (state_unit >= 0)
+ unregister_sound_special(state_unit);
+ if (sq_unit >= 0)
+ unregister_sound_dsp(sq_unit);
return -ENODEV;
}
irq_installed = 1;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sound/oss/dmasound: unregister OSS devices on init failure
2026-11-27 4:55 [PATCH] sound/oss/dmasound: unregister OSS devices on init failure Haoxiang Li
@ 2026-11-27 17:34 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-11-27 17:34 UTC (permalink / raw)
To: Haoxiang Li; +Cc: perex, tiwai, cassiogabrielcontato, tim.bird, linux-sound
On Fri, 27 Nov 2026 05:55:09 +0100,
Haoxiang Li wrote:
>
> dmasound_init() registers dsp, special sound and mixer device
> but never unregisters if something fails. Unregister the devices
> in the error handling path so a failed initialization leaves
> no stale OSS registrations. Also fix some code styles.
>
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Applied to for-next branch. Thanks.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-27 17:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 4:55 [PATCH] sound/oss/dmasound: unregister OSS devices on init failure Haoxiang Li
2026-11-27 17:34 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox