]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xen: balloon: Replace sprintf() with sysfs_emit()
authorYash Suthar <yashsuthar983@gmail.com>
Sun, 17 May 2026 13:38:17 +0000 (19:08 +0530)
committerJuergen Gross <jgross@suse.com>
Mon, 8 Jun 2026 07:01:49 +0000 (09:01 +0200)
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: Yash Suthar <yashsuthar983@gmail.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20260517133817.29691-1-yashsuthar983@gmail.com>

drivers/xen/xen-balloon.c

index b293d7652f15593532b9483422bcc56cbaae8cd9..67b0e2dbe84a639673d9d0f724cfce7705e1a84f 100644 (file)
@@ -138,7 +138,7 @@ EXPORT_SYMBOL_GPL(xen_balloon_init);
                                   struct device_attribute *attr,       \
                                   char *buf)                           \
        {                                                               \
-               return sprintf(buf, format, ##args);                    \
+               return sysfs_emit(buf, format, ##args);                 \
        }                                                               \
        static DEVICE_ATTR_RO(name)
 
@@ -155,7 +155,7 @@ static DEVICE_BOOL_ATTR(scrub_pages, 0644, xen_scrub_pages);
 static ssize_t target_kb_show(struct device *dev, struct device_attribute *attr,
                              char *buf)
 {
-       return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages));
+       return sysfs_emit(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages));
 }
 
 static ssize_t target_kb_store(struct device *dev,
@@ -180,7 +180,7 @@ static DEVICE_ATTR_RW(target_kb);
 static ssize_t target_show(struct device *dev, struct device_attribute *attr,
                           char *buf)
 {
-       return sprintf(buf, "%llu\n",
+       return sysfs_emit(buf, "%llu\n",
                       (unsigned long long)balloon_stats.target_pages
                       << PAGE_SHIFT);
 }