Commit b8e13154 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: seq: Do error checks at creating system ports

snd_seq_system_client_init() doesn't check the errors returned from
its port creations.  Let's do it properly and handle the error paths.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c4f1957e
...@@ -123,6 +123,7 @@ int __init snd_seq_system_client_init(void) ...@@ -123,6 +123,7 @@ int __init snd_seq_system_client_init(void)
{ {
struct snd_seq_port_callback pcallbacks; struct snd_seq_port_callback pcallbacks;
struct snd_seq_port_info *port; struct snd_seq_port_info *port;
int err;
port = kzalloc(sizeof(*port), GFP_KERNEL); port = kzalloc(sizeof(*port), GFP_KERNEL);
if (!port) if (!port)
...@@ -148,7 +149,10 @@ int __init snd_seq_system_client_init(void) ...@@ -148,7 +149,10 @@ int __init snd_seq_system_client_init(void)
port->flags = SNDRV_SEQ_PORT_FLG_GIVEN_PORT; port->flags = SNDRV_SEQ_PORT_FLG_GIVEN_PORT;
port->addr.client = sysclient; port->addr.client = sysclient;
port->addr.port = SNDRV_SEQ_PORT_SYSTEM_TIMER; port->addr.port = SNDRV_SEQ_PORT_SYSTEM_TIMER;
snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_CREATE_PORT, port); err = snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_CREATE_PORT,
port);
if (err < 0)
goto error_port;
/* register announcement port */ /* register announcement port */
strcpy(port->name, "Announce"); strcpy(port->name, "Announce");
...@@ -158,16 +162,24 @@ int __init snd_seq_system_client_init(void) ...@@ -158,16 +162,24 @@ int __init snd_seq_system_client_init(void)
port->flags = SNDRV_SEQ_PORT_FLG_GIVEN_PORT; port->flags = SNDRV_SEQ_PORT_FLG_GIVEN_PORT;
port->addr.client = sysclient; port->addr.client = sysclient;
port->addr.port = SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE; port->addr.port = SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE;
snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_CREATE_PORT, port); err = snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_CREATE_PORT,
port);
if (err < 0)
goto error_port;
announce_port = port->addr.port; announce_port = port->addr.port;
kfree(port); kfree(port);
return 0; return 0;
error_port:
snd_seq_system_client_done();
kfree(port);
return err;
} }
/* unregister our internal client */ /* unregister our internal client */
void __exit snd_seq_system_client_done(void) void snd_seq_system_client_done(void)
{ {
int oldsysclient = sysclient; int oldsysclient = sysclient;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment