Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+2 -6
+2 -6
sound/core/seq/seq_clientmgr.c
··· 1199 1199 /* it is not allowed to create the port for an another client */ 1200 1200 if (info->addr.client != client->number) 1201 1201 return -EPERM; 1202 + if (client->type == USER_CLIENT && info->kernel) 1203 + return -EINVAL; 1202 1204 1203 1205 if (info->flags & SNDRV_SEQ_PORT_FLG_GIVEN_PORT) 1204 1206 port_idx = info->addr.port; ··· 1210 1208 if (err < 0) 1211 1209 return err; 1212 1210 1213 - if (client->type == USER_CLIENT && info->kernel) { 1214 - port_idx = port->addr.port; 1215 - snd_seq_port_unlock(port); 1216 - snd_seq_delete_port(client, port_idx); 1217 - return -EINVAL; 1218 - } 1219 1211 if (client->type == KERNEL_CLIENT) { 1220 1212 callback = info->kernel; 1221 1213 if (callback) {