]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: seq: Restore created port information after insertion
authorCássio Gabriel <cassiogabrielcontato@gmail.com>
Tue, 2 Jun 2026 10:55:46 +0000 (07:55 -0300)
committerTakashi Iwai <tiwai@suse.de>
Tue, 2 Jun 2026 17:48:40 +0000 (19:48 +0200)
Commit 2ee646353cd5 ("ALSA: seq: Register kernel port with full
information") split sequencer port creation from list insertion so a
port can be filled before it becomes visible.

However, snd_seq_ioctl_create_port() still copies port->addr back to the
ioctl argument before snd_seq_insert_port() assigns the final port
number. A successful SNDRV_SEQ_IOCTL_CREATE_PORT without
SNDRV_SEQ_PORT_FLG_GIVEN_PORT can therefore report port -1 to userspace.

Move the ioctl address copy after successful insertion, and keep the
default "port-%d" name assignment from overwriting a caller-provided port
name. This restores the observable behavior from before the split while
keeping the port populated before publication.

Fixes: 2ee646353cd5 ("ALSA: seq: Register kernel port with full information")
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260602-alsa-seq-create-port-info-fix-v1-1-eec0280131e9@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/seq/seq_clientmgr.c
sound/core/seq/seq_ports.c

index 19d6fea012f6ae37d5bc4c0565bf49b989464542..81ef461a91183dd67f9716df87bc243e05768f30 100644 (file)
@@ -1306,14 +1306,13 @@ static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg)
                }
        }
 
-       info->addr = port->addr;
-
        snd_seq_set_port_info(port, info);
        err = snd_seq_insert_port(client, port_idx, port);
        if (err < 0) {
                kfree(port);
                return err;
        }
+       info->addr = port->addr;
        if (info->capability & SNDRV_SEQ_PORT_CAP_UMP_ENDPOINT)
                client->ump_endpoint_port = port->addr.port;
        snd_seq_system_client_ev_port_start(port->addr.client, port->addr.port);
index 17daacd4476aaa7e5bf368a3e11d4246cf632c97..6612e92d801f5f2993d9817fa23d40e6a7cb47cf 100644 (file)
@@ -170,7 +170,8 @@ int snd_seq_insert_port(struct snd_seq_client *client, int port,
        list_add_tail(&new_port->list, insert_before);
        client->num_ports++;
        new_port->addr.port = num;      /* store the port number in the port */
-       sprintf(new_port->name, "port-%d", num);
+       if (!new_port->name[0])
+               sprintf(new_port->name, "port-%d", num);
 
        return num;
 }