Re: [PATCH v4] of/pci: Fix memory leak in of_pci_get_host_bridge_resources

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

 



Hi Jeffy,

[auto build test ERROR on pci/next]
[also build test ERROR on v4.11-rc5 next-20170405]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jeffy-Chen/of-pci-Fix-memory-leak-in-of_pci_get_host_bridge_resources/20170406-005941
base:   https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: i386-randconfig-n0-04051821 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers//of/of_pci.c: In function 'of_pci_get_host_bridge_resources':
>> drivers//of/of_pci.c:215:30: error: incompatible type for argument 2 of 'pci_add_resource'
     pci_add_resource(resources, res);
                                 ^~~
   In file included from include/linux/of_pci.h:4:0,
                    from drivers//of/of_pci.c:8:
   include/linux/pci.h:1152:6: note: expected 'struct resource *' but argument is of type 'struct resource'
    void pci_add_resource(struct list_head *resources, struct resource *res);
         ^~~~~~~~~~~~~~~~
>> drivers//of/of_pci.c:261:9: error: invalid type argument of '->' (have 'struct resource')
         res->start - range.pci_addr);
            ^~
>> drivers//of/of_pci.c:260:38: error: incompatible type for argument 2 of 'pci_add_resource_offset'
      pci_add_resource_offset(resources, res,
                                         ^~~
   In file included from include/linux/of_pci.h:4:0,
                    from drivers//of/of_pci.c:8:
   include/linux/pci.h:1153:6: note: expected 'struct resource *' but argument is of type 'struct resource'
    void pci_add_resource_offset(struct list_head *resources, struct resource *res,
         ^~~~~~~~~~~~~~~~~~~~~~~

vim +/pci_add_resource +215 drivers//of/of_pci.c

   209		} else {
   210			if (res.end > res.start + bus_max)
   211				res.end = res.start + bus_max;
   212		}
   213	
   214		res.flags |= IORESOURCE_AUTO;
 > 215		pci_add_resource(resources, res);
   216	
   217		/* Check for ranges property */
   218		err = of_pci_range_parser_init(&parser, dev);
   219		if (err)
   220			goto parse_failed;
   221	
   222		pr_debug("Parsing ranges property...\n");
   223		for_each_of_pci_range(&parser, &range) {
   224			/* Read next ranges element */
   225			if ((range.flags & IORESOURCE_TYPE_BITS) == IORESOURCE_IO)
   226				snprintf(range_type, 4, " IO");
   227			else if ((range.flags & IORESOURCE_TYPE_BITS) == IORESOURCE_MEM)
   228				snprintf(range_type, 4, "MEM");
   229			else
   230				snprintf(range_type, 4, "err");
   231			pr_info("  %s %#010llx..%#010llx -> %#010llx\n", range_type,
   232				range.cpu_addr, range.cpu_addr + range.size - 1,
   233				range.pci_addr);
   234	
   235			/*
   236			 * If we failed translation or got a zero-sized region
   237			 * then skip this range
   238			 */
   239			if (range.cpu_addr == OF_BAD_ADDR || range.size == 0)
   240				continue;
   241	
   242			err = of_pci_range_to_resource(&range, dev, &res);
   243			if (err)
   244				continue;
   245	
   246			if (resource_type(&res) == IORESOURCE_IO) {
   247				if (!io_base) {
   248					pr_err("I/O range found for %s. Please provide an io_base pointer to save CPU base address\n",
   249						dev->full_name);
   250					err = -EINVAL;
   251					goto parse_failed;
   252				}
   253				if (*io_base != (resource_size_t)OF_BAD_ADDR)
   254					pr_warn("More than one I/O resource converted for %s. CPU base address for old range lost!\n",
   255						dev->full_name);
   256				*io_base = range.cpu_addr;
   257			}
   258	
   259			res.flags |= IORESOURCE_AUTO;
 > 260			pci_add_resource_offset(resources, res,
 > 261						res->start - range.pci_addr);
   262		}
   263	
   264		return 0;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

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