Re: [PATCH v3 2/3] gpio: pcie-idio-24: Migrate to the regmap API

From: Dan Carpenter
Date: Mon Mar 06 2023 - 03:32:36 EST


Hi William,

url: https://github.com/intel-lab-lkp/linux/commits/William-Breathitt-Gray/regmap-Pass-irq_drv_data-as-a-parameter-for-set_type_config/20230306-010313
base: 4827aae061337251bb91801b316157a78b845ec7
patch link: https://lore.kernel.org/r/278e328cd1689a4e331e7515050c12c29f2a4785.1678034378.git.william.gray%40linaro.org
patch subject: [PATCH v3 2/3] gpio: pcie-idio-24: Migrate to the regmap API
config: loongarch-randconfig-m041-20230305 (https://download.01.org/0day-ci/archive/20230306/202303060606.ooBzB3pr-lkp@xxxxxxxxx/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <error27@xxxxxxxxx>
| Link: https://lore.kernel.org/r/202303060606.ooBzB3pr-lkp@xxxxxxxxx/

smatch warnings:
drivers/gpio/gpio-pcie-idio-24.c:365 idio_24_probe() error: potentially dereferencing uninitialized 'idio24gpio'.

vim +/idio24gpio +365 drivers/gpio/gpio-pcie-idio-24.c

58556204662812 William Breathitt Gray 2018-01-09 330 static int idio_24_probe(struct pci_dev *pdev, const struct pci_device_id *id)
58556204662812 William Breathitt Gray 2018-01-09 331 {
58556204662812 William Breathitt Gray 2018-01-09 332 struct device *const dev = &pdev->dev;
58556204662812 William Breathitt Gray 2018-01-09 333 struct idio_24_gpio *idio24gpio;
58556204662812 William Breathitt Gray 2018-01-09 334 int err;
10a2f11d3c9e48 Arnaud de Turckheim 2020-11-04 335 const size_t pci_plx_bar_index = 1;
58556204662812 William Breathitt Gray 2018-01-09 336 const size_t pci_bar_index = 2;
58556204662812 William Breathitt Gray 2018-01-09 337 const char *const name = pci_name(pdev);
e60d5c32ff098c William Breathitt Gray 2023-03-05 338 struct gpio_regmap_config gpio_config = {};
e60d5c32ff098c William Breathitt Gray 2023-03-05 339 void __iomem *pex8311_intcsr;
e60d5c32ff098c William Breathitt Gray 2023-03-05 340 void __iomem *idio_24_regs;
e60d5c32ff098c William Breathitt Gray 2023-03-05 341 struct regmap *pex8311_intcsr_map;
e60d5c32ff098c William Breathitt Gray 2023-03-05 342 struct regmap_irq_chip *chip;
e60d5c32ff098c William Breathitt Gray 2023-03-05 343 struct regmap_irq_chip_data *chip_data;
58556204662812 William Breathitt Gray 2018-01-09 344
58556204662812 William Breathitt Gray 2018-01-09 345 err = pcim_enable_device(pdev);
58556204662812 William Breathitt Gray 2018-01-09 346 if (err) {
58556204662812 William Breathitt Gray 2018-01-09 347 dev_err(dev, "Failed to enable PCI device (%d)\n", err);
58556204662812 William Breathitt Gray 2018-01-09 348 return err;
58556204662812 William Breathitt Gray 2018-01-09 349 }
58556204662812 William Breathitt Gray 2018-01-09 350
10a2f11d3c9e48 Arnaud de Turckheim 2020-11-04 351 err = pcim_iomap_regions(pdev, BIT(pci_plx_bar_index) | BIT(pci_bar_index), name);
58556204662812 William Breathitt Gray 2018-01-09 352 if (err) {
58556204662812 William Breathitt Gray 2018-01-09 353 dev_err(dev, "Unable to map PCI I/O addresses (%d)\n", err);
58556204662812 William Breathitt Gray 2018-01-09 354 return err;
58556204662812 William Breathitt Gray 2018-01-09 355 }
58556204662812 William Breathitt Gray 2018-01-09 356
e60d5c32ff098c William Breathitt Gray 2023-03-05 357 pex8311_intcsr = pcim_iomap_table(pdev)[pci_plx_bar_index] + PLX_PEX8311_PCI_LCS_INTCSR;
e60d5c32ff098c William Breathitt Gray 2023-03-05 358 idio_24_regs = pcim_iomap_table(pdev)[pci_bar_index];
e60d5c32ff098c William Breathitt Gray 2023-03-05 359
e60d5c32ff098c William Breathitt Gray 2023-03-05 360 pex8311_intcsr_map = devm_regmap_init_mmio(dev, pex8311_intcsr,
e60d5c32ff098c William Breathitt Gray 2023-03-05 361 &pex8311_intcsr_regmap_config);
e60d5c32ff098c William Breathitt Gray 2023-03-05 362 if (IS_ERR(pex8311_intcsr_map))
e60d5c32ff098c William Breathitt Gray 2023-03-05 363 return dev_err_probe(dev, PTR_ERR(pex8311_intcsr_map),
e60d5c32ff098c William Breathitt Gray 2023-03-05 364 "Unable to initialize PEX8311 register map\n");
e60d5c32ff098c William Breathitt Gray 2023-03-05 @365 idio24gpio->map = devm_regmap_init_mmio(dev, idio_24_regs,
e60d5c32ff098c William Breathitt Gray 2023-03-05 366 &idio_24_regmap_config);

Heh. This needs to be after the idio24gpio = devm_kzalloc().

e60d5c32ff098c William Breathitt Gray 2023-03-05 367 if (IS_ERR(idio24gpio->map))
e60d5c32ff098c William Breathitt Gray 2023-03-05 368 return dev_err_probe(dev, PTR_ERR(idio24gpio->map),
e60d5c32ff098c William Breathitt Gray 2023-03-05 369 "Unable to initialize register map\n");
e60d5c32ff098c William Breathitt Gray 2023-03-05 370
e60d5c32ff098c William Breathitt Gray 2023-03-05 371 idio24gpio = devm_kzalloc(dev, sizeof(*idio24gpio), GFP_KERNEL);
e60d5c32ff098c William Breathitt Gray 2023-03-05 372 if (!idio24gpio)
e60d5c32ff098c William Breathitt Gray 2023-03-05 373 return -ENOMEM;
e60d5c32ff098c William Breathitt Gray 2023-03-05 374
e60d5c32ff098c William Breathitt Gray 2023-03-05 375 mutex_init(&idio24gpio->lock);
e60d5c32ff098c William Breathitt Gray 2023-03-05 376
e60d5c32ff098c William Breathitt Gray 2023-03-05 377 /* Initialize all IRQ type configuration to IRQ_TYPE_EDGE_BOTH */
e60d5c32ff098c William Breathitt Gray 2023-03-05 378 idio24gpio->irq_type = GENMASK(7, 0);
e60d5c32ff098c William Breathitt Gray 2023-03-05 379
e60d5c32ff098c William Breathitt Gray 2023-03-05 380 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
e60d5c32ff098c William Breathitt Gray 2023-03-05 381 if (!chip)
e60d5c32ff098c William Breathitt Gray 2023-03-05 382 return -ENOMEM;
e60d5c32ff098c William Breathitt Gray 2023-03-05 383
e60d5c32ff098c William Breathitt Gray 2023-03-05 384 chip->name = name;

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