* [PATCH RESEND] sparc: vio: use sysfs_emit in sysfs show functions
@ 2026-05-04 18:13 Thorsten Blum
2026-06-04 15:27 ` Thorsten Blum
2026-06-09 13:24 ` Andreas Larsson
0 siblings, 2 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-05-04 18:13 UTC (permalink / raw)
To: David S. Miller, Andreas Larsson, Thorsten Blum, Kees Cook
Cc: sparclinux, linux-kernel
Replace sprintf() and scnprintf() with sysfs_emit() in sysfs show
functions. sysfs_emit() is preferred to format sysfs output as it
provides better bounds checking.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/sparc/kernel/vio.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c
index 8b4f55047716..b7b06752a038 100644
--- a/arch/sparc/kernel/vio.c
+++ b/arch/sparc/kernel/vio.c
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
+#include <linux/sysfs.h>
#include <linux/irq.h>
#include <linux/export.h>
#include <linux/init.h>
@@ -121,7 +122,7 @@ static ssize_t devspec_show(struct device *dev,
else if (!strcmp(vdev->type, "vdc-port"))
str = "vdisk";
- return sprintf(buf, "%s\n", str);
+ return sysfs_emit(buf, "%s\n", str);
}
static DEVICE_ATTR_RO(devspec);
@@ -129,7 +130,7 @@ static ssize_t type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct vio_dev *vdev = to_vio_dev(dev);
- return sprintf(buf, "%s\n", vdev->type);
+ return sysfs_emit(buf, "%s\n", vdev->type);
}
static DEVICE_ATTR_RO(type);
@@ -138,7 +139,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
{
const struct vio_dev *vdev = to_vio_dev(dev);
- return sprintf(buf, "vio:T%sS%s\n", vdev->type, vdev->compat);
+ return sysfs_emit(buf, "vio:T%sS%s\n", vdev->type, vdev->compat);
}
static DEVICE_ATTR_RO(modalias);
@@ -192,7 +193,7 @@ show_pciobppath_attr(struct device *dev, struct device_attribute *attr,
vdev = to_vio_dev(dev);
dp = vdev->dp;
- return scnprintf(buf, PAGE_SIZE, "%pOF\n", dp);
+ return sysfs_emit(buf, "%pOF\n", dp);
}
static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] sparc: vio: use sysfs_emit in sysfs show functions
2026-05-04 18:13 [PATCH RESEND] sparc: vio: use sysfs_emit in sysfs show functions Thorsten Blum
@ 2026-06-04 15:27 ` Thorsten Blum
2026-06-09 13:24 ` Andreas Larsson
1 sibling, 0 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-06-04 15:27 UTC (permalink / raw)
To: David S. Miller, Andreas Larsson, Kees Cook; +Cc: sparclinux, linux-kernel
Gentle ping?
On Mon, May 04, 2026 at 08:13:20PM +0200, Thorsten Blum wrote:
> Replace sprintf() and scnprintf() with sysfs_emit() in sysfs show
> functions. sysfs_emit() is preferred to format sysfs output as it
> provides better bounds checking.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> arch/sparc/kernel/vio.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c
> index 8b4f55047716..b7b06752a038 100644
> --- a/arch/sparc/kernel/vio.c
> +++ b/arch/sparc/kernel/vio.c
> @@ -13,6 +13,7 @@
> #include <linux/kernel.h>
> #include <linux/slab.h>
> #include <linux/string.h>
> +#include <linux/sysfs.h>
> #include <linux/irq.h>
> #include <linux/export.h>
> #include <linux/init.h>
> @@ -121,7 +122,7 @@ static ssize_t devspec_show(struct device *dev,
> else if (!strcmp(vdev->type, "vdc-port"))
> str = "vdisk";
>
> - return sprintf(buf, "%s\n", str);
> + return sysfs_emit(buf, "%s\n", str);
> }
> static DEVICE_ATTR_RO(devspec);
>
> @@ -129,7 +130,7 @@ static ssize_t type_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> struct vio_dev *vdev = to_vio_dev(dev);
> - return sprintf(buf, "%s\n", vdev->type);
> + return sysfs_emit(buf, "%s\n", vdev->type);
> }
> static DEVICE_ATTR_RO(type);
>
> @@ -138,7 +139,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
> {
> const struct vio_dev *vdev = to_vio_dev(dev);
>
> - return sprintf(buf, "vio:T%sS%s\n", vdev->type, vdev->compat);
> + return sysfs_emit(buf, "vio:T%sS%s\n", vdev->type, vdev->compat);
> }
> static DEVICE_ATTR_RO(modalias);
>
> @@ -192,7 +193,7 @@ show_pciobppath_attr(struct device *dev, struct device_attribute *attr,
> vdev = to_vio_dev(dev);
> dp = vdev->dp;
>
> - return scnprintf(buf, PAGE_SIZE, "%pOF\n", dp);
> + return sysfs_emit(buf, "%pOF\n", dp);
> }
>
> static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND] sparc: vio: use sysfs_emit in sysfs show functions
2026-05-04 18:13 [PATCH RESEND] sparc: vio: use sysfs_emit in sysfs show functions Thorsten Blum
2026-06-04 15:27 ` Thorsten Blum
@ 2026-06-09 13:24 ` Andreas Larsson
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Larsson @ 2026-06-09 13:24 UTC (permalink / raw)
To: Thorsten Blum, David S. Miller, Kees Cook; +Cc: sparclinux, linux-kernel
On 2026-05-04 20:13, Thorsten Blum wrote:
> Replace sprintf() and scnprintf() with sysfs_emit() in sysfs show
> functions. sysfs_emit() is preferred to format sysfs output as it
> provides better bounds checking.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> arch/sparc/kernel/vio.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c
> index 8b4f55047716..b7b06752a038 100644
> --- a/arch/sparc/kernel/vio.c
> +++ b/arch/sparc/kernel/vio.c
> @@ -13,6 +13,7 @@
> #include <linux/kernel.h>
> #include <linux/slab.h>
> #include <linux/string.h>
> +#include <linux/sysfs.h>
> #include <linux/irq.h>
> #include <linux/export.h>
> #include <linux/init.h>
> @@ -121,7 +122,7 @@ static ssize_t devspec_show(struct device *dev,
> else if (!strcmp(vdev->type, "vdc-port"))
> str = "vdisk";
>
> - return sprintf(buf, "%s\n", str);
> + return sysfs_emit(buf, "%s\n", str);
> }
> static DEVICE_ATTR_RO(devspec);
>
> @@ -129,7 +130,7 @@ static ssize_t type_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> struct vio_dev *vdev = to_vio_dev(dev);
> - return sprintf(buf, "%s\n", vdev->type);
> + return sysfs_emit(buf, "%s\n", vdev->type);
> }
> static DEVICE_ATTR_RO(type);
>
> @@ -138,7 +139,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
> {
> const struct vio_dev *vdev = to_vio_dev(dev);
>
> - return sprintf(buf, "vio:T%sS%s\n", vdev->type, vdev->compat);
> + return sysfs_emit(buf, "vio:T%sS%s\n", vdev->type, vdev->compat);
> }
> static DEVICE_ATTR_RO(modalias);
>
> @@ -192,7 +193,7 @@ show_pciobppath_attr(struct device *dev, struct device_attribute *attr,
> vdev = to_vio_dev(dev);
> dp = vdev->dp;
>
> - return scnprintf(buf, PAGE_SIZE, "%pOF\n", dp);
> + return sysfs_emit(buf, "%pOF\n", dp);
> }
>
> static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH,
Reviewed-by: Andreas Larsson <andreas@gaisler.com>
Tested-by: Andreas Larsson <andreas@gaisler.com>
Picking this up to my for-next.
Thanks,
Andreas
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH RESEND] sparc: vio: Use sysfs_emit in sysfs show functions
@ 2026-03-09 22:44 Thorsten Blum
0 siblings, 0 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-03-09 22:44 UTC (permalink / raw)
To: David S. Miller, Andreas Larsson, Thorsten Blum, Kees Cook
Cc: sparclinux, linux-kernel
Replace sprintf() and scnprintf() with sysfs_emit() in sysfs show
functions. sysfs_emit() is preferred to format sysfs output as it
provides better bounds checking.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/sparc/kernel/vio.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c
index 8b4f55047716..b7b06752a038 100644
--- a/arch/sparc/kernel/vio.c
+++ b/arch/sparc/kernel/vio.c
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
+#include <linux/sysfs.h>
#include <linux/irq.h>
#include <linux/export.h>
#include <linux/init.h>
@@ -121,7 +122,7 @@ static ssize_t devspec_show(struct device *dev,
else if (!strcmp(vdev->type, "vdc-port"))
str = "vdisk";
- return sprintf(buf, "%s\n", str);
+ return sysfs_emit(buf, "%s\n", str);
}
static DEVICE_ATTR_RO(devspec);
@@ -129,7 +130,7 @@ static ssize_t type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct vio_dev *vdev = to_vio_dev(dev);
- return sprintf(buf, "%s\n", vdev->type);
+ return sysfs_emit(buf, "%s\n", vdev->type);
}
static DEVICE_ATTR_RO(type);
@@ -138,7 +139,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
{
const struct vio_dev *vdev = to_vio_dev(dev);
- return sprintf(buf, "vio:T%sS%s\n", vdev->type, vdev->compat);
+ return sysfs_emit(buf, "vio:T%sS%s\n", vdev->type, vdev->compat);
}
static DEVICE_ATTR_RO(modalias);
@@ -192,7 +193,7 @@ show_pciobppath_attr(struct device *dev, struct device_attribute *attr,
vdev = to_vio_dev(dev);
dp = vdev->dp;
- return scnprintf(buf, PAGE_SIZE, "%pOF\n", dp);
+ return sysfs_emit(buf, "%pOF\n", dp);
}
static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH,
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-09 13:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-04 18:13 [PATCH RESEND] sparc: vio: use sysfs_emit in sysfs show functions Thorsten Blum
2026-06-04 15:27 ` Thorsten Blum
2026-06-09 13:24 ` Andreas Larsson
-- strict thread matches above, loose matches on Subject: below --
2026-03-09 22:44 [PATCH RESEND] sparc: vio: Use " Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome