* [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource
@ 2026-10-21 3:13 LiuJunyuan
2026-10-21 6:01 ` Dan Carpenter
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: LiuJunyuan @ 2026-10-21 3:13 UTC (permalink / raw)
To: gregkh; +Cc: linux-staging, linux-kernel, LiuJunyuan
Replace sprintf() with scnprintf() when formatting the resource name.
Signed-off-by: LiuJunyuan <2058432396@qq.com>
---
drivers/staging/vme_user/vme_tsi148.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/vme_user/vme_tsi148.c b/drivers/staging/vme_user/vme_tsi148.c
index 9447c00bc013..a0a7c8341995 100644
--- a/drivers/staging/vme_user/vme_tsi148.c
+++ b/drivers/staging/vme_user/vme_tsi148.c
@@ -745,8 +745,8 @@ static int tsi148_alloc_resource(struct vme_master_resource *image,
}
}
- sprintf((char *)image->bus_resource.name, "%s.%d", tsi148_bridge->name,
- image->number);
+ scnprintf(image->bus_resource.name, VMENAMSIZ + 3, "%s.%d",
+ tsi148_bridge->name, image->number);
image->bus_resource.start = 0;
image->bus_resource.end = (unsigned long)size;
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource
2026-10-21 3:13 [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource LiuJunyuan
@ 2026-10-21 6:01 ` Dan Carpenter
2026-10-21 6:15 ` Greg KH
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2026-10-21 6:01 UTC (permalink / raw)
To: LiuJunyuan; +Cc: gregkh, linux-staging, linux-kernel
On Wed, Oct 21, 2026 at 11:13:49AM +0800, LiuJunyuan wrote:
> Replace sprintf() with scnprintf() when formatting the resource name.
>
> Signed-off-by: LiuJunyuan <2058432396@qq.com>
Is this a fix or a cleanup?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource
2026-10-21 3:13 [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource LiuJunyuan
2026-10-21 6:01 ` Dan Carpenter
@ 2026-10-21 6:15 ` Greg KH
2026-10-21 9:01 ` David Laight
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2026-10-21 6:15 UTC (permalink / raw)
To: LiuJunyuan; +Cc: linux-staging, linux-kernel
On Wed, Oct 21, 2026 at 11:13:49AM +0800, LiuJunyuan wrote:
> Replace sprintf() with scnprintf() when formatting the resource name.
Why? That's a requirement for your changelog text.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource
2026-10-21 3:13 [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource LiuJunyuan
2026-10-21 6:01 ` Dan Carpenter
2026-10-21 6:15 ` Greg KH
@ 2026-10-21 9:01 ` David Laight
2026-10-23 13:36 ` Greg KH
2026-10-24 2:25 ` kernel test robot
4 siblings, 0 replies; 6+ messages in thread
From: David Laight @ 2026-10-21 9:01 UTC (permalink / raw)
To: LiuJunyuan; +Cc: gregkh, linux-staging, linux-kernel
On Wed, 21 Oct 2026 11:13:49 +0800
LiuJunyuan <2058432396@qq.com> wrote:
> Replace sprintf() with scnprintf() when formatting the resource name.
>
> Signed-off-by: LiuJunyuan <2058432396@qq.com>
> ---
> drivers/staging/vme_user/vme_tsi148.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/vme_user/vme_tsi148.c b/drivers/staging/vme_user/vme_tsi148.c
> index 9447c00bc013..a0a7c8341995 100644
> --- a/drivers/staging/vme_user/vme_tsi148.c
> +++ b/drivers/staging/vme_user/vme_tsi148.c
> @@ -745,8 +745,8 @@ static int tsi148_alloc_resource(struct vme_master_resource *image,
> }
> }
>
> - sprintf((char *)image->bus_resource.name, "%s.%d", tsi148_bridge->name,
> - image->number);
> + scnprintf(image->bus_resource.name, VMENAMSIZ + 3, "%s.%d",
That looks like a very strange size...
David
> + tsi148_bridge->name, image->number);
>
> image->bus_resource.start = 0;
> image->bus_resource.end = (unsigned long)size;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource
2026-10-21 3:13 [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource LiuJunyuan
` (2 preceding siblings ...)
2026-10-21 9:01 ` David Laight
@ 2026-10-23 13:36 ` Greg KH
2026-10-24 2:25 ` kernel test robot
4 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2026-10-23 13:36 UTC (permalink / raw)
To: LiuJunyuan; +Cc: linux-staging, linux-kernel
On Wed, Oct 21, 2026 at 11:13:49AM +0800, LiuJunyuan wrote:
> Replace sprintf() with scnprintf() when formatting the resource name.
Why?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource
2026-10-21 3:13 [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource LiuJunyuan
` (3 preceding siblings ...)
2026-10-23 13:36 ` Greg KH
@ 2026-10-24 2:25 ` kernel test robot
4 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-10-24 2:25 UTC (permalink / raw)
To: LiuJunyuan, gregkh; +Cc: oe-kbuild-all, linux-staging, linux-kernel, LiuJunyuan
Hi LiuJunyuan,
kernel test robot noticed the following build warnings:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/intel-lab-lkp/linux/commits/LiuJunyuan/staging-vme_user-use-scnprintf-in-tsi148_alloc_resource/20261021-111349
base: staging/staging-testing
patch link: https://lore.kernel.org/r/tencent_F5EEA06B3CD49F9EFF5C185259BF4134DA0A%40qq.com
patch subject: [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource
config: i386-randconfig-1006-20261021 (https://download.01.org/0day-ci/archive/20261024/202610241010.ezQcs5lj-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261024/202610241010.ezQcs5lj-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610241010.ezQcs5lj-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/staging/vme_user/vme_tsi148.c: In function 'tsi148_alloc_resource':
>> drivers/staging/vme_user/vme_tsi148.c:748:38: warning: passing argument 1 of 'scnprintf' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
748 | scnprintf(image->bus_resource.name, VMENAMSIZ + 3, "%s.%d",
| ~~~~~~~~~~~~~~~~~~~^~~~~
In file included from include/linux/kernel.h:32,
from include/linux/random.h:7,
from include/linux/nodemask.h:94,
from include/linux/numa.h:6,
from include/linux/cpumask.h:15,
from arch/x86/include/asm/paravirt.h:19,
from arch/x86/include/asm/irqflags.h:100,
from include/linux/irqflags.h:18,
from arch/x86/include/asm/special_insns.h:10,
from arch/x86/include/asm/processor.h:25,
from arch/x86/include/asm/timex.h:5,
from include/linux/timex.h:67,
from include/linux/time32.h:13,
from include/linux/time.h:60,
from include/linux/stat.h:19,
from include/linux/module.h:13,
from drivers/staging/vme_user/vme_tsi148.c:12:
include/linux/sprintf.h:15:36: note: expected 'char *' but argument is of type 'const char *'
15 | __printf(3, 4) int scnprintf(char *buf, size_t size, const char *fmt, ...);
| ~~~~~~^~~
vim +748 drivers/staging/vme_user/vme_tsi148.c
705
706 /*
707 * Allocate and map PCI Resource
708 */
709 static int tsi148_alloc_resource(struct vme_master_resource *image,
710 unsigned long long size)
711 {
712 unsigned long long existing_size;
713 int retval = 0;
714 struct pci_dev *pdev;
715 struct vme_bridge *tsi148_bridge;
716
717 tsi148_bridge = image->parent;
718
719 pdev = to_pci_dev(tsi148_bridge->parent);
720
721 existing_size = (unsigned long long)(image->bus_resource.end -
722 image->bus_resource.start);
723
724 /* If the existing size is OK, return */
725 if ((size != 0) && (existing_size == (size - 1)))
726 return 0;
727
728 if (existing_size != 0) {
729 iounmap(image->kern_base);
730 image->kern_base = NULL;
731 kfree(image->bus_resource.name);
732 release_resource(&image->bus_resource);
733 memset(&image->bus_resource, 0, sizeof(image->bus_resource));
734 }
735
736 /* Exit here if size is zero */
737 if (size == 0)
738 return 0;
739
740 if (!image->bus_resource.name) {
741 image->bus_resource.name = kmalloc(VMENAMSIZ + 3, GFP_ATOMIC);
742 if (!image->bus_resource.name) {
743 retval = -ENOMEM;
744 goto err_name;
745 }
746 }
747
> 748 scnprintf(image->bus_resource.name, VMENAMSIZ + 3, "%s.%d",
749 tsi148_bridge->name, image->number);
750
751 image->bus_resource.start = 0;
752 image->bus_resource.end = (unsigned long)size;
753 image->bus_resource.flags = IORESOURCE_MEM;
754
755 retval = pci_bus_alloc_resource(pdev->bus, &image->bus_resource,
756 size, 0x10000, PCIBIOS_MIN_MEM,
757 0, NULL, NULL);
758 if (retval) {
759 dev_err(tsi148_bridge->parent, "Failed to allocate mem resource for window %d size 0x%lx start 0x%lx\n",
760 image->number, (unsigned long)size,
761 (unsigned long)image->bus_resource.start);
762 goto err_resource;
763 }
764
765 image->kern_base = ioremap(image->bus_resource.start, size);
766 if (!image->kern_base) {
767 dev_err(tsi148_bridge->parent, "Failed to remap resource\n");
768 retval = -ENOMEM;
769 goto err_remap;
770 }
771
772 return 0;
773
774 err_remap:
775 release_resource(&image->bus_resource);
776 err_resource:
777 kfree(image->bus_resource.name);
778 memset(&image->bus_resource, 0, sizeof(image->bus_resource));
779 err_name:
780 return retval;
781 }
782
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-10-24 2:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21 3:13 [PATCH] staging: vme_user: use scnprintf in tsi148_alloc_resource LiuJunyuan
2026-10-21 6:01 ` Dan Carpenter
2026-10-21 6:15 ` Greg KH
2026-10-21 9:01 ` David Laight
2026-10-23 13:36 ` Greg KH
2026-10-24 2:25 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox