Re: [PATCH v1] usb: typec: fusb302: Free log buffers on exit
From: Sebastian Andrzej Siewior
Date: Wed Aug 26 2026 - 04:47:53 EST
On 2026-08-08 09:10:28 [+0200], Greg KH wrote:
> > --- a/drivers/usb/typec/tcpm/fusb302.c
> > +++ b/drivers/usb/typec/tcpm/fusb302.c
> > @@ -223,7 +223,16 @@ static void fusb302_debugfs_init(struct fusb302_chip *chip)
> >
> > static void fusb302_debugfs_exit(struct fusb302_chip *chip)
> > {
> > + int i;
> > +
> > debugfs_remove(chip->dentry);
> > +
> > + mutex_lock(&chip->logbuffer_lock);
> > + for (i = 0; i < LOG_BUFFER_ENTRIES; i++) {
> > + kfree(chip->logbuffer[i]);
> > + chip->logbuffer[i] = NULL;
> > + }
> > + mutex_unlock(&chip->logbuffer_lock);
>
> As you are tearing things down here, and there is no actual user, why is
> the lock needed? And if so, can you just use a guard() instead?
That is correct. The whole thing is about vanish so locking is not
needed.
Looking at the actual user of that buffer, I'm curious if it wouldn't be
better to use dev_err()/ dev_info() for some of the output and other
which are just pure informative/ debug kind of information, hide behind
a trace event which can be enabled if needed.
> thanks,
>
> greg k-h
Sebastian