The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] ALSA: seq: Restore created port information after insertion
@ 2026-06-02 10:55 Cássio Gabriel
  2026-06-02 17:54 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Cássio Gabriel @ 2026-06-02 10:55 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela
  Cc: linux-sound, linux-kernel, notify, Cássio Gabriel

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>
---
 sound/core/seq/seq_clientmgr.c | 3 +--
 sound/core/seq/seq_ports.c     | 3 ++-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 19d6fea012f6..81ef461a9118 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -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);
diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c
index 17daacd4476a..6612e92d801f 100644
--- a/sound/core/seq/seq_ports.c
+++ b/sound/core/seq/seq_ports.c
@@ -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;
 }

---
base-commit: 96d4780e9ff5168195e891c474a85bb0d510fe9f
change-id: 20260601-alsa-seq-create-port-info-fix-81457ed3c864

Best regards,
--  
Cássio Gabriel <cassiogabrielcontato@gmail.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: seq: Restore created port information after insertion
  2026-06-02 10:55 [PATCH] ALSA: seq: Restore created port information after insertion Cássio Gabriel
@ 2026-06-02 17:54 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-06-02 17:54 UTC (permalink / raw)
  To: Cássio Gabriel
  Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel, notify

On Tue, 02 Jun 2026 12:55:46 +0200,
Cássio Gabriel wrote:
> 
> 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>

Thanks, applied now to for-next branch.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-02 17:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-02 10:55 [PATCH] ALSA: seq: Restore created port information after insertion Cássio Gabriel
2026-06-02 17:54 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox