* [PATCH][next] powerpc/ps3: replace open-coded sysfs_emit function
@ 2024-10-19 2:13 Paulo Miguel Almeida
2024-10-21 7:31 ` Geert Uytterhoeven
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Paulo Miguel Almeida @ 2024-10-19 2:13 UTC (permalink / raw)
To: geoff, mpe, npiggin, christophe.leroy, naveen, maddy,
linuxppc-dev, linux-kernel
Cc: paulo.miguel.almeida.rodenas, linux-hardening
sysfs_emit() helper function should be used when formatting the value
to be returned to user space.
This patch replaces open-coded sysfs_emit() in sysfs .show() callbacks
Link: https://github.com/KSPP/linux/issues/105
Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
---
arch/powerpc/platforms/ps3/system-bus.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index b9a7d9bae687..afbaabf182d0 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -453,10 +453,9 @@ static ssize_t modalias_show(struct device *_dev, struct device_attribute *a,
char *buf)
{
struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
- int len = snprintf(buf, PAGE_SIZE, "ps3:%d:%d\n", dev->match_id,
- dev->match_sub_id);
- return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
+ return sysfs_emit(buf, "ps3:%d:%d\n", dev->match_id,
+ dev->match_sub_id);
}
static DEVICE_ATTR_RO(modalias);
--
2.47.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next] powerpc/ps3: replace open-coded sysfs_emit function
2024-10-19 2:13 [PATCH][next] powerpc/ps3: replace open-coded sysfs_emit function Paulo Miguel Almeida
@ 2024-10-21 7:31 ` Geert Uytterhoeven
2024-10-21 8:49 ` Geoff Levand
2024-11-17 12:09 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2024-10-21 7:31 UTC (permalink / raw)
To: Paulo Miguel Almeida
Cc: geoff, mpe, npiggin, christophe.leroy, naveen, maddy,
linuxppc-dev, linux-kernel, linux-hardening
On Sat, Oct 19, 2024 at 4:14 AM Paulo Miguel Almeida
<paulo.miguel.almeida.rodenas@gmail.com> wrote:
> sysfs_emit() helper function should be used when formatting the value
> to be returned to user space.
>
> This patch replaces open-coded sysfs_emit() in sysfs .show() callbacks
>
> Link: https://github.com/KSPP/linux/issues/105
> Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] powerpc/ps3: replace open-coded sysfs_emit function
2024-10-19 2:13 [PATCH][next] powerpc/ps3: replace open-coded sysfs_emit function Paulo Miguel Almeida
2024-10-21 7:31 ` Geert Uytterhoeven
@ 2024-10-21 8:49 ` Geoff Levand
2024-11-17 12:09 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Geoff Levand @ 2024-10-21 8:49 UTC (permalink / raw)
To: Paulo Miguel Almeida, mpe, npiggin, christophe.leroy, naveen,
maddy, linuxppc-dev, linux-kernel
Cc: linux-hardening
Hi Paulo,
On 10/19/24 11:13, Paulo Miguel Almeida wrote:
> sysfs_emit() helper function should be used when formatting the value
> to be returned to user space.
>
> This patch replaces open-coded sysfs_emit() in sysfs .show() callbacks
>
> Link: https://github.com/KSPP/linux/issues/105
> Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
> ---
> arch/powerpc/platforms/ps3/system-bus.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
> index b9a7d9bae687..afbaabf182d0 100644
> --- a/arch/powerpc/platforms/ps3/system-bus.c
> +++ b/arch/powerpc/platforms/ps3/system-bus.c
> @@ -453,10 +453,9 @@ static ssize_t modalias_show(struct device *_dev, struct device_attribute *a,
> char *buf)
> {
> struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
> - int len = snprintf(buf, PAGE_SIZE, "ps3:%d:%d\n", dev->match_id,
> - dev->match_sub_id);
>
> - return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
> + return sysfs_emit(buf, "ps3:%d:%d\n", dev->match_id,
> + dev->match_sub_id);
> }
> static DEVICE_ATTR_RO(modalias);
I tested this on PS3 and it seems to work OK.
Thanks for your contribution.
Acked-by: Geoff Levand <geoff@infradead.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] powerpc/ps3: replace open-coded sysfs_emit function
2024-10-19 2:13 [PATCH][next] powerpc/ps3: replace open-coded sysfs_emit function Paulo Miguel Almeida
2024-10-21 7:31 ` Geert Uytterhoeven
2024-10-21 8:49 ` Geoff Levand
@ 2024-11-17 12:09 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2024-11-17 12:09 UTC (permalink / raw)
To: geoff, mpe, npiggin, christophe.leroy, naveen, maddy,
linuxppc-dev, linux-kernel, Paulo Miguel Almeida
Cc: linux-hardening
On Sat, 19 Oct 2024 15:13:49 +1300, Paulo Miguel Almeida wrote:
> sysfs_emit() helper function should be used when formatting the value
> to be returned to user space.
>
> This patch replaces open-coded sysfs_emit() in sysfs .show() callbacks
>
>
Applied to powerpc/next.
[1/1] powerpc/ps3: replace open-coded sysfs_emit function
https://git.kernel.org/powerpc/c/2866949ec889cf383c481119c617b9cead733070
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-17 12:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-19 2:13 [PATCH][next] powerpc/ps3: replace open-coded sysfs_emit function Paulo Miguel Almeida
2024-10-21 7:31 ` Geert Uytterhoeven
2024-10-21 8:49 ` Geoff Levand
2024-11-17 12:09 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).