From ecb84a3e7e7cccd7578d8b4c57035e98cd89901f Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Tue, 29 Apr 2025 08:55:02 +0200 Subject: genirq/debugfs: Convert to lock guards Convert all lock/unlock pairs to guards and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/all/20250429065420.620200108@linutronix.de --- kernel/irq/debugfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'kernel/irq/debugfs.c') diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c index ca142b9a4db3..9004a17b93a2 100644 --- a/kernel/irq/debugfs.c +++ b/kernel/irq/debugfs.c @@ -160,7 +160,7 @@ static int irq_debug_show(struct seq_file *m, void *p) struct irq_desc *desc = m->private; struct irq_data *data; - raw_spin_lock_irq(&desc->lock); + guard(raw_spinlock_irq)(&desc->lock); data = irq_desc_get_irq_data(desc); seq_printf(m, "handler: %ps\n", desc->handle_irq); seq_printf(m, "device: %s\n", desc->dev_name); @@ -178,7 +178,6 @@ static int irq_debug_show(struct seq_file *m, void *p) seq_printf(m, "node: %d\n", irq_data_get_node(data)); irq_debug_show_masks(m, desc); irq_debug_show_data(m, data, 0); - raw_spin_unlock_irq(&desc->lock); return 0; } -- cgit v1.2.3 From 47af06c9d31fe558493de4e04f9a07847dc4992f Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 9 May 2025 18:46:42 +0300 Subject: genirq: Consistently use '%u' format specifier for unsigned int variables There are three cases in the genirq code when the irq, as an unsigned integer variable, is converted to text representation by sprintf(). In two cases it uses '%d' specifier which is for signed values. While it's not a problem right now, potentially it might be in the future in case too big (> INT_MAX) number will appear there. Consistently use '%u' format specifier for @irq which is declared as unsigned int in all these cases. Signed-off-by: Andy Shevchenko Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/all/20250509154643.1499171-1-andriy.shevchenko@linux.intel.com --- kernel/irq/debugfs.c | 2 +- kernel/irq/proc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'kernel/irq/debugfs.c') diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c index 9004a17b93a2..3d6a5b3cfaf3 100644 --- a/kernel/irq/debugfs.c +++ b/kernel/irq/debugfs.c @@ -230,7 +230,7 @@ void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc) if (!irq_dir || !desc || desc->debugfs_file) return; - sprintf(name, "%d", irq); + sprintf(name, "%u", irq); desc->debugfs_file = debugfs_create_file(name, 0644, irq_dir, desc, &dfs_irq_ops); } diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 94eba9a425c4..29c2404e743b 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -309,7 +309,7 @@ static bool name_unique(unsigned int irq, struct irqaction *new_action) void register_handler_proc(unsigned int irq, struct irqaction *action) { - char name [MAX_NAMELEN]; + char name[MAX_NAMELEN]; struct irq_desc *desc = irq_to_desc(irq); if (!desc->dir || action->dir || !action->name || !name_unique(irq, action)) @@ -345,7 +345,7 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc) return; /* create /proc/irq/1234 */ - sprintf(name, "%d", irq); + sprintf(name, "%u", irq); desc->dir = proc_mkdir(name, root_irq_dir); if (!desc->dir) return; -- cgit v1.2.3 From a4a39c81e1043b153bde3ef5cb3cf94222ffd918 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 15 May 2025 11:55:16 +0300 Subject: genirq: Bump the size of the local variable for sprintf() GCC is not happy about a sprintf() call on a buffer that might be too small for the given formatting string. kernel/irq/debugfs.c:233:26: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=] Fix this by bumping the size of the local variable for sprintf(). Reported-by: kernel test robot Signed-off-by: Andy Shevchenko Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/all/20250515085516.2913290-1-andriy.shevchenko@linux.intel.com Closes: https://lore.kernel.org/oe-kbuild-all/202505151057.xbyXAbEn-lkp@intel.com/ --- kernel/irq/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kernel/irq/debugfs.c') diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c index 3d6a5b3cfaf3..3527defd2890 100644 --- a/kernel/irq/debugfs.c +++ b/kernel/irq/debugfs.c @@ -225,7 +225,7 @@ void irq_debugfs_copy_devname(int irq, struct device *dev) void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc) { - char name [10]; + char name [12]; if (!irq_dir || !desc || desc->debugfs_file) return; -- cgit v1.2.3