lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202401260821.tiWXcPF2-lkp@intel.com>
Date: Fri, 26 Jan 2024 08:16:07 +0800
From: kernel test robot <lkp@...el.com>
To: Nagarjuna Kristam <nkristam@...dia.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
	Thierry Reding <treding@...dia.com>
Subject: drivers/usb/gadget/udc/tegra-xudc.c:3417:60: warning: '%d' directive
 output may be truncated writing between 1 and 10 bytes into a region of size
 2

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   ecb1b8288dc7ccbdcb3b9df005fa1c0e0c0388a7
commit: b4e19931c98a088fbd80b5c3f892261c9a0e6c23 usb: gadget: tegra-xudc: Support multiple device modes
date:   3 years, 10 months ago
config: arm64-randconfig-002-20240106 (https://download.01.org/0day-ci/archive/20240126/202401260821.tiWXcPF2-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240126/202401260821.tiWXcPF2-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@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401260821.tiWXcPF2-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/usb/gadget/udc/tegra-xudc.c: In function 'tegra_xudc_phy_get':
>> drivers/usb/gadget/udc/tegra-xudc.c:3417:60: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=]
    3417 |                 snprintf(phy_name, sizeof(phy_name), "usb3-%d", usb3);
         |                                                            ^~
   drivers/usb/gadget/udc/tegra-xudc.c:3417:54: note: directive argument in the range [0, 2147483647]
    3417 |                 snprintf(phy_name, sizeof(phy_name), "usb3-%d", usb3);
         |                                                      ^~~~~~~~~
   drivers/usb/gadget/udc/tegra-xudc.c:3417:17: note: 'snprintf' output between 7 and 16 bytes into a destination of size 7
    3417 |                 snprintf(phy_name, sizeof(phy_name), "usb3-%d", usb3);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +3417 drivers/usb/gadget/udc/tegra-xudc.c

  3360	
  3361	static int tegra_xudc_phy_get(struct tegra_xudc *xudc)
  3362	{
  3363		int err = 0, usb3;
  3364		unsigned int i;
  3365	
  3366		xudc->utmi_phy = devm_kcalloc(xudc->dev, xudc->soc->num_phys,
  3367						   sizeof(*xudc->utmi_phy), GFP_KERNEL);
  3368		if (!xudc->utmi_phy)
  3369			return -ENOMEM;
  3370	
  3371		xudc->usb3_phy = devm_kcalloc(xudc->dev, xudc->soc->num_phys,
  3372						   sizeof(*xudc->usb3_phy), GFP_KERNEL);
  3373		if (!xudc->usb3_phy)
  3374			return -ENOMEM;
  3375	
  3376		xudc->usbphy = devm_kcalloc(xudc->dev, xudc->soc->num_phys,
  3377						   sizeof(*xudc->usbphy), GFP_KERNEL);
  3378		if (!xudc->usbphy)
  3379			return -ENOMEM;
  3380	
  3381		xudc->vbus_nb.notifier_call = tegra_xudc_vbus_notify;
  3382	
  3383		for (i = 0; i < xudc->soc->num_phys; i++) {
  3384			char phy_name[] = "usb.-.";
  3385	
  3386			/* Get USB2 phy */
  3387			snprintf(phy_name, sizeof(phy_name), "usb2-%d", i);
  3388			xudc->utmi_phy[i] = devm_phy_optional_get(xudc->dev, phy_name);
  3389			if (IS_ERR(xudc->utmi_phy[i])) {
  3390				err = PTR_ERR(xudc->utmi_phy[i]);
  3391				if (err != -EPROBE_DEFER)
  3392					dev_err(xudc->dev, "failed to get usb2-%d phy: %d\n",
  3393						i, err);
  3394	
  3395				goto clean_up;
  3396			} else if (xudc->utmi_phy[i]) {
  3397				/* Get usb-phy, if utmi phy is available */
  3398				xudc->usbphy[i] = devm_usb_get_phy_by_node(xudc->dev,
  3399							xudc->utmi_phy[i]->dev.of_node,
  3400							&xudc->vbus_nb);
  3401				if (IS_ERR(xudc->usbphy[i])) {
  3402					err = PTR_ERR(xudc->usbphy[i]);
  3403					dev_err(xudc->dev, "failed to get usbphy-%d: %d\n",
  3404						i, err);
  3405					goto clean_up;
  3406				}
  3407			} else if (!xudc->utmi_phy[i]) {
  3408				/* if utmi phy is not available, ignore USB3 phy get */
  3409				continue;
  3410			}
  3411	
  3412			/* Get USB3 phy */
  3413			usb3 = tegra_xusb_padctl_get_usb3_companion(xudc->padctl, i);
  3414			if (usb3 < 0)
  3415				continue;
  3416	
> 3417			snprintf(phy_name, sizeof(phy_name), "usb3-%d", usb3);
  3418			xudc->usb3_phy[i] = devm_phy_optional_get(xudc->dev, phy_name);
  3419			if (IS_ERR(xudc->usb3_phy[i])) {
  3420				err = PTR_ERR(xudc->usb3_phy[i]);
  3421				if (err != -EPROBE_DEFER)
  3422					dev_err(xudc->dev, "failed to get usb3-%d phy: %d\n",
  3423						usb3, err);
  3424	
  3425				goto clean_up;
  3426			} else if (xudc->usb3_phy[i])
  3427				dev_dbg(xudc->dev, "usb3_phy-%d registered", usb3);
  3428		}
  3429	
  3430		return err;
  3431	
  3432	clean_up:
  3433		for (i = 0; i < xudc->soc->num_phys; i++) {
  3434			xudc->usb3_phy[i] = NULL;
  3435			xudc->utmi_phy[i] = NULL;
  3436			xudc->usbphy[i] = NULL;
  3437		}
  3438	
  3439		return err;
  3440	}
  3441	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ