Re: [PATCH] firewire: core: clean up modalias buffer handling
Takashi Sakamoto <[email protected]> Mon, 30 Mar 2026 09:57:48 +0900
| Newsgroups | gmane.linux.kernel,gmane.linux.kernel.firewire.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Thanks for sending your patch. On Sun, Mar 29, 2026 at 11:19:40PM +0200, Thorsten Blum wrote: > Use scnprintf() in get_modalias() to return the number of characters > actually written to the destination buffer. > > Also reserve space for the trailing newline in modalias_show() and > append it explicitly, instead of using strcpy() and relying on the > formatted modalias to fit within PAGE_SIZE. > > While the current code is safe, this makes the sysfs buffer handling > more explicit and consistent. > > Signed-off-by: Thorsten Blum <[email protected]> > --- > drivers/firewire/core-device.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) I previously considered using sysfs_emit(_at)() in the code, but decided against it because the code is called in both sysfs and the workqueue context of firewire devices. The buffer size differs between these cases (either PAGE_SIZE or 64). In any case, as you already noted, the current code is enough safe. The total length of formatted string is fixed (= 41 + 1) by the format template, so it is unlikely to cause issues. I have little motivation to change it. Thanks Takashi Sakamoto