Replace sprintf() with sysfs_emit() in sysfs show functions. sysfs_emit() is preferred for formatting sysfs output because it provides safer bounds checking. No functional changes.
Unified · Split
| @@ -6,6 +6,7 @@ · 5 unmodified lines | ||
| 6 | 6 | #include <linux/cc_platform.h> |
| 7 | 7 | #include <linux/configfs.h> |
| 8 | 8 | #include <linux/module.h> |
| 9 | +#include <linux/sysfs.h> | |
| 9 | 10 | |
| 10 | 11 | #define KEY_NUM_MAX 128 /* maximum dm crypt keys */ |
| 11 | 12 | #define KEY_SIZE_MAX 256 /* maximum dm crypt key size */ |
| @@ -189,7 +190,7 @@ static inline struct config_key *to_config_key(struct config_item *item) · 177 unmodified lines | ||
| 189 | 190 | |
| 190 | 191 | static ssize_t config_key_description_show(struct config_item *item, char *page) |
| 191 | 192 | { |
| 192 | − return sprintf(page, "%s\n", to_config_key(item)->description); | |
| 193 | + return sysfs_emit(page, "%s\n", to_config_key(item)->description); | |
| 193 | 194 | } |
| 194 | 195 | |
| 195 | 196 | static ssize_t config_key_description_store(struct config_item *item, |
| @@ -265,7 +266,7 @@ static struct config_item *config_keys_make_item(struct config_group *group, · 69 unmodified lines | ||
| 265 | 266 | |
| 266 | 267 | static ssize_t config_keys_count_show(struct config_item *item, char *page) |
| 267 | 268 | { |
| 268 | − return sprintf(page, "%d\n", key_count); | |
| 269 | + return sysfs_emit(page, "%d\n", key_count); | |
| 269 | 270 | } |
| 270 | 271 | |
| 271 | 272 | CONFIGFS_ATTR_RO(config_keys_, count); |
| @@ -274,7 +275,7 @@ static bool is_dm_key_reused; · 2 unmodified lines | ||
| 274 | 275 | |
| 275 | 276 | static ssize_t config_keys_reuse_show(struct config_item *item, char *page) |
| 276 | 277 | { |
| 277 | − return sprintf(page, "%d\n", is_dm_key_reused); | |
| 278 | + return sysfs_emit(page, "%d\n", is_dm_key_reused); | |
| 278 | 279 | } |
| 279 | 280 | |
| 280 | 281 | static ssize_t config_keys_reuse_store(struct config_item *item, |
| @@ -321,7 +322,7 @@ static bool restore; · 40 unmodified lines | ||
| 321 | 322 | |
| 322 | 323 | static ssize_t config_keys_restore_show(struct config_item *item, char *page) |
| 323 | 324 | { |
| 324 | − return sprintf(page, "%d\n", restore); | |
| 325 | + return sysfs_emit(page, "%d\n", restore); | |
| 325 | 326 | } |
| 326 | 327 | |
| 327 | 328 | static ssize_t config_keys_restore_store(struct config_item *item, |