Re: [PATCH RESEND v2 22/26] ALSA: info: let procfs own the seq_file of text entries

From: Jann Horn

Date: Thu Nov 05 2026 - 16:56:52 EST


On Thu, Nov 5, 2026 at 10:52 PM Jann Horn <jannh@xxxxxxxxxx> wrote:
> On Wed, Nov 4, 2026 at 8:47 PM Christian Brauner <brauner@xxxxxxxxxx> wrote:
> > Declare the show function and let procfs open and free the seq_file.
> > ->proc_open() only sets up the private data and preallocates the buffer
> > now and ->proc_release() no longer releases the seq_file. Reading an
> > entry then no longer holds up its removal when the card goes away.
> [...]
> > + goto error;
> > + }
> > + m->private = data;
> > return 0;
> >
> > error:
> > @@ -387,7 +388,6 @@ static int snd_info_text_entry_release(struct inode *inode, struct file *file)
> > if (data->wbuffer && entry->c.text.write)
> > entry->c.text.write(entry, data->wbuffer);
> >
> > - single_release(inode, file);
> > kfree(data->rbuffer);
> > if (data->wbuffer) {
> > kvfree(data->wbuffer->buffer);
> > @@ -401,11 +401,10 @@ static int snd_info_text_entry_release(struct inode *inode, struct file *file)
> >
> > static const struct proc_ops snd_info_text_entry_ops =
> > {
> > + .proc_show = snd_info_seq_show,
> > .proc_open = snd_info_text_entry_open,
> > .proc_release = snd_info_text_entry_release,
> > .proc_write = snd_info_text_entry_write,
> > - .proc_lseek = seq_lseek,
> > - .proc_read = seq_read,
> > };
>
> Is this safe? Looking at the work.procfs.cleanup tree, the
> proc_release handler (snd_info_text_entry_release()) can call
> `entry->c.text.write(entry, data->wbuffer)`, and the only kind of
> reference dropped by snd_info_text_entry_release() is a module
> reference.
>
> I think the entry could concurrently get freed by snd_info_free_entry()?

Ah, no, this is fine because ->proc_release still happens at the same
time as before.

Sorry for the noise, should've thought a minute more.