[PATCH RESEND] drm: xe: Replace sprintf() with sysfs_emit()

Madhur Kumar posted 1 patch 1 month, 3 weeks ago
drivers/gpu/drm/xe/xe_pmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH RESEND] drm: xe: Replace sprintf() with sysfs_emit()
Posted by Madhur Kumar 1 month, 3 weeks ago
Replace sprintf() calls with sysfs_emit() to follow current kernel
coding standards.

sysfs_emit() is the preferred method for formatting sysfs output as it
provides better bounds checking and is more secure.

Signed-off-by: Madhur Kumar <madhurkumar004@gmail.com>
---
 drivers/gpu/drm/xe/xe_pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_pmu.c b/drivers/gpu/drm/xe/xe_pmu.c
index cab51d826345..f016459c9904 100644
--- a/drivers/gpu/drm/xe/xe_pmu.c
+++ b/drivers/gpu/drm/xe/xe_pmu.c
@@ -425,7 +425,7 @@ static ssize_t event_attr_show(struct device *dev,
 	struct perf_pmu_events_attr *pmu_attr =
 		container_of(attr, struct perf_pmu_events_attr, attr);
 
-	return sprintf(buf, "event=%#04llx\n", pmu_attr->id);
+	return sysfs_emit(buf, "event=%#04llx\n", pmu_attr->id);
 }
 
 #define XE_EVENT_ATTR(name_, v_, id_)					\
-- 
2.52.0
Re: [PATCH RESEND] drm: xe: Replace sprintf() with sysfs_emit()
Posted by Rodrigo Vivi 1 month, 2 weeks ago
On Sun, Dec 14, 2025 at 02:06:59PM +0530, Madhur Kumar wrote:
> Replace sprintf() calls with sysfs_emit() to follow current kernel
> coding standards.
> 
> sysfs_emit() is the preferred method for formatting sysfs output as it
> provides better bounds checking and is more secure.
> 
> Signed-off-by: Madhur Kumar <madhurkumar004@gmail.com>

Thanks for the patch.
I just did a small adjustment in the patch subject while getting it
pushed to drm-xe-next.

[drm-xe-next af90706f0eec] drm/xe/pmu: Replace sprintf() with sysfs_emit()

> ---
>  drivers/gpu/drm/xe/xe_pmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_pmu.c b/drivers/gpu/drm/xe/xe_pmu.c
> index cab51d826345..f016459c9904 100644
> --- a/drivers/gpu/drm/xe/xe_pmu.c
> +++ b/drivers/gpu/drm/xe/xe_pmu.c
> @@ -425,7 +425,7 @@ static ssize_t event_attr_show(struct device *dev,
>  	struct perf_pmu_events_attr *pmu_attr =
>  		container_of(attr, struct perf_pmu_events_attr, attr);
>  
> -	return sprintf(buf, "event=%#04llx\n", pmu_attr->id);
> +	return sysfs_emit(buf, "event=%#04llx\n", pmu_attr->id);
>  }
>  
>  #define XE_EVENT_ATTR(name_, v_, id_)					\
> -- 
> 2.52.0
>