[pci:wip/bjorn-vpd-v2 5/9] drivers/pci/vpd.c:88:19: warning: format '%zu' expects argument of type 'size_t', but argument 3 has type 'int'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git wip/bjorn-vpd-v2
head:   d4466f3225fe2067d1a815ce03e1ab7abc6c3c28
commit: 49c5c3061498060f93d08a2386503596e0ff14be [5/9] PCI/VPD: Don't check Large Resource Item Names for validity
config: arm64-randconfig-r001-20210730 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/commit/?id=49c5c3061498060f93d08a2386503596e0ff14be
        git remote add pci https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
        git fetch --no-tags pci wip/bjorn-vpd-v2
        git checkout 49c5c3061498060f93d08a2386503596e0ff14be
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   In file included from include/linux/device.h:15,
                    from include/linux/pci.h:37,
                    from drivers/pci/vpd.c:8:
   drivers/pci/vpd.c: In function 'pci_vpd_size':
>> drivers/pci/vpd.c:88:19: warning: format '%zu' expects argument of type 'size_t', but argument 3 has type 'int' [-Wformat=]
      88 |     pci_warn(dev, "failed VPD read at offset %zu\n",
         |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
      19 | #define dev_fmt(fmt) fmt
         |                      ^~~
   include/linux/pci.h:2465:37: note: in expansion of macro 'dev_warn'
    2465 | #define pci_warn(pdev, fmt, arg...) dev_warn(&(pdev)->dev, fmt, ##arg)
         |                                     ^~~~~~~~
   drivers/pci/vpd.c:88:5: note: in expansion of macro 'pci_warn'
      88 |     pci_warn(dev, "failed VPD read at offset %zu\n",
         |     ^~~~~~~~
   drivers/pci/vpd.c:88:48: note: format string is defined here
      88 |     pci_warn(dev, "failed VPD read at offset %zu\n",
         |                                              ~~^
         |                                                |
         |                                                long unsigned int
         |                                              %u
   In file included from include/linux/device.h:15,
                    from include/linux/pci.h:37,
                    from drivers/pci/vpd.c:8:
   drivers/pci/vpd.c:88:19: warning: too many arguments for format [-Wformat-extra-args]
      88 |     pci_warn(dev, "failed VPD read at offset %zu\n",
         |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
      19 | #define dev_fmt(fmt) fmt
         |                      ^~~
   include/linux/pci.h:2465:37: note: in expansion of macro 'dev_warn'
    2465 | #define pci_warn(pdev, fmt, arg...) dev_warn(&(pdev)->dev, fmt, ##arg)
         |                                     ^~~~~~~~
   drivers/pci/vpd.c:88:5: note: in expansion of macro 'pci_warn'
      88 |     pci_warn(dev, "failed VPD read at offset %zu\n",
         |     ^~~~~~~~


vim +88 drivers/pci/vpd.c

b55ac1b22690d2 Matt Carlson    2010-02-26   @8  #include <linux/pci.h>
f0eb77ae6b857b Bjorn Helgaas   2018-03-19    9  #include <linux/delay.h>
363c75db1d7bbd Paul Gortmaker  2011-05-27   10  #include <linux/export.h>
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   11  #include <linux/sched/signal.h>
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   12  #include "pci.h"
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   13  
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   14  /* VPD access through PCI 2.2+ VPD capability */
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   15  
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   16  struct pci_vpd_ops {
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   17  	ssize_t (*read)(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   18  	ssize_t (*write)(struct pci_dev *dev, loff_t pos, size_t count, const void *buf);
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   19  };
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   20  
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   21  struct pci_vpd {
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   22  	const struct pci_vpd_ops *ops;
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   23  	struct mutex	lock;
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   24  	unsigned int	len;
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   25  	u16		flag;
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   26  	u8		cap;
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   27  	unsigned int	busy:1;
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   28  	unsigned int	valid:1;
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   29  };
f9ea894ca59a7a Bjorn Helgaas   2018-03-19   30  
5881b38912f3f4 Heiner Kallweit 2021-04-16   31  static struct pci_dev *pci_get_func0_dev(struct pci_dev *dev)
5881b38912f3f4 Heiner Kallweit 2021-04-16   32  {
5881b38912f3f4 Heiner Kallweit 2021-04-16   33  	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
5881b38912f3f4 Heiner Kallweit 2021-04-16   34  }
5881b38912f3f4 Heiner Kallweit 2021-04-16   35  
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   36  /**
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   37   * pci_read_vpd - Read one entry from Vital Product Data
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   38   * @dev:	pci device struct
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   39   * @pos:	offset in vpd space
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   40   * @count:	number of bytes to read
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   41   * @buf:	pointer to where to store result
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   42   */
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   43  ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf)
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   44  {
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   45  	if (!dev->vpd || !dev->vpd->ops)
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   46  		return -ENODEV;
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   47  	return dev->vpd->ops->read(dev, pos, count, buf);
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   48  }
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   49  EXPORT_SYMBOL(pci_read_vpd);
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   50  
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   51  /**
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   52   * pci_write_vpd - Write entry to Vital Product Data
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   53   * @dev:	pci device struct
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   54   * @pos:	offset in vpd space
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   55   * @count:	number of bytes to write
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   56   * @buf:	buffer containing write data
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   57   */
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   58  ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf)
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   59  {
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   60  	if (!dev->vpd || !dev->vpd->ops)
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   61  		return -ENODEV;
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   62  	return dev->vpd->ops->write(dev, pos, count, buf);
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   63  }
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   64  EXPORT_SYMBOL(pci_write_vpd);
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   65  
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   66  #define PCI_VPD_MAX_SIZE (PCI_VPD_ADDR_MASK + 1)
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   67  
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   68  /**
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   69   * pci_vpd_size - determine actual size of Vital Product Data
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   70   * @dev:	pci device struct
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   71   * @old_size:	current assumed size, also maximum allowed size
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   72   */
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   73  static size_t pci_vpd_size(struct pci_dev *dev, size_t old_size)
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   74  {
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   75  	size_t off = 0;
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   76  	unsigned char header[1+2];	/* 1 byte tag, 2 bytes length */
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   77  
d1df5f3f4cfff8 Heiner Kallweit 2021-04-01   78  	while (off < old_size && pci_read_vpd(dev, off, 1, header) == 1) {
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   79  		unsigned char tag;
aa956bff1e1de2 Bjorn Helgaas   2021-07-15   80  		size_t size;
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   81  
4e0d77f8e831fc Heiner Kallweit 2021-07-29   82  		if (off == 0 && (header[0] == 0x00 || header[0] == 0xff))
4e0d77f8e831fc Heiner Kallweit 2021-07-29   83  			goto error;
d1df5f3f4cfff8 Heiner Kallweit 2021-04-01   84  
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   85  		if (header[0] & PCI_VPD_LRDT) {
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   86  			/* Large Resource Data Type Tag */
49c5c306149806 Bjorn Helgaas   2021-07-15   87  			if (pci_read_vpd(dev, off + 1, 2, &header[1]) != 2) {
e2cdd86b561719 Bjorn Helgaas   2021-07-15  @88  				pci_warn(dev, "failed VPD read at offset %zu\n",
49c5c306149806 Bjorn Helgaas   2021-07-15   89  					 tag, off + 1);
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   90  				return 0;
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   91  			}
aa956bff1e1de2 Bjorn Helgaas   2021-07-15   92  			size = pci_vpd_lrdt_size(header);
aa956bff1e1de2 Bjorn Helgaas   2021-07-15   93  			if (off + size > PCI_VPD_MAX_SIZE)
aa956bff1e1de2 Bjorn Helgaas   2021-07-15   94  				goto error;
aa956bff1e1de2 Bjorn Helgaas   2021-07-15   95  
aa956bff1e1de2 Bjorn Helgaas   2021-07-15   96  			off += PCI_VPD_LRDT_TAG_SIZE + size;
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   97  		} else {
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   98  			/* Short Resource Data Type Tag */
f0eb77ae6b857b Bjorn Helgaas   2018-03-19   99  			tag = pci_vpd_srdt_tag(header);
aa956bff1e1de2 Bjorn Helgaas   2021-07-15  100  			size = pci_vpd_srdt_size(header);
aa956bff1e1de2 Bjorn Helgaas   2021-07-15  101  			if (size == 0 || off + size > PCI_VPD_MAX_SIZE)
aa956bff1e1de2 Bjorn Helgaas   2021-07-15  102  				goto error;
aa956bff1e1de2 Bjorn Helgaas   2021-07-15  103  
aa956bff1e1de2 Bjorn Helgaas   2021-07-15  104  			off += PCI_VPD_SRDT_TAG_SIZE + size;
f0eb77ae6b857b Bjorn Helgaas   2018-03-19  105  			if (tag == PCI_VPD_STIN_END)	/* End tag descriptor */
f0eb77ae6b857b Bjorn Helgaas   2018-03-19  106  				return off;
f0eb77ae6b857b Bjorn Helgaas   2018-03-19  107  		}
f0eb77ae6b857b Bjorn Helgaas   2018-03-19  108  	}
f0eb77ae6b857b Bjorn Helgaas   2018-03-19  109  	return 0;
4e0d77f8e831fc Heiner Kallweit 2021-07-29  110  
4e0d77f8e831fc Heiner Kallweit 2021-07-29  111  error:
4e0d77f8e831fc Heiner Kallweit 2021-07-29  112  	pci_info(dev, "invalid VPD tag %#04x at offset %zu%s\n",
4e0d77f8e831fc Heiner Kallweit 2021-07-29  113  		 header[0], off, off == 0 ?
4e0d77f8e831fc Heiner Kallweit 2021-07-29  114  		 "; assume missing optional EEPROM" : "");
4e0d77f8e831fc Heiner Kallweit 2021-07-29  115  	return 0;
f0eb77ae6b857b Bjorn Helgaas   2018-03-19  116  }
f0eb77ae6b857b Bjorn Helgaas   2018-03-19  117  

:::::: The code at line 88 was first introduced by commit
:::::: e2cdd86b561719da9ac928635f2a55b370dbb5b1 PCI/VPD: Correct diagnostic for VPD read failure

:::::: TO: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
:::::: CC: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux