Skip to content

Commit 4f92eb7

Browse files
committed
ALSA: seq: Check validity before creating a port object
The client type and the port info validity check should be done before actually creating a port, instead of unnecessary create-and-scratch. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20230523075358.9672-23-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 7c3f0d3 commit 4f92eb7

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

sound/core/seq/seq_clientmgr.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,8 @@ static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg)
11991199
/* it is not allowed to create the port for an another client */
12001200
if (info->addr.client != client->number)
12011201
return -EPERM;
1202+
if (client->type == USER_CLIENT && info->kernel)
1203+
return -EINVAL;
12021204

12031205
if (info->flags & SNDRV_SEQ_PORT_FLG_GIVEN_PORT)
12041206
port_idx = info->addr.port;
@@ -1208,12 +1210,6 @@ static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg)
12081210
if (err < 0)
12091211
return err;
12101212

1211-
if (client->type == USER_CLIENT && info->kernel) {
1212-
port_idx = port->addr.port;
1213-
snd_seq_port_unlock(port);
1214-
snd_seq_delete_port(client, port_idx);
1215-
return -EINVAL;
1216-
}
12171213
if (client->type == KERNEL_CLIENT) {
12181214
callback = info->kernel;
12191215
if (callback) {

0 commit comments

Comments
 (0)