mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Antonio Borneo <antonio.borneo@foss.st.com>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org, Marc Zyngier <maz@kernel.org>
Subject: drivers/irqchip/irq-stm32-exti.c:719 stm32_exti_h_domain_alloc() warn: variable dereferenced before check 'host_data->drv_data' (see line 707)
Date: Mon, 15 Aug 2022 09:51:54 +0300	[thread overview]
Message-ID: <202208131739.gJvcs9ls-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   69dac8e431af26173ca0a1ebc87054e01c585bcc
commit: c297493336b7bc0c12ced484a9e61d04ec2d9403 irqchip/stm32-exti: Simplify irq description table
config: arm-randconfig-m041-20220812 (https://download.01.org/0day-ci/archive/20220813/202208131739.gJvcs9ls-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/irqchip/irq-stm32-exti.c:719 stm32_exti_h_domain_alloc() warn: variable dereferenced before check 'host_data->drv_data' (see line 707)

vim +719 drivers/irqchip/irq-stm32-exti.c

927abfc4461e7fd7 Ludovic Barre    2018-04-26  692  static int stm32_exti_h_domain_alloc(struct irq_domain *dm,
927abfc4461e7fd7 Ludovic Barre    2018-04-26  693  				     unsigned int virq,
927abfc4461e7fd7 Ludovic Barre    2018-04-26  694  				     unsigned int nr_irqs, void *data)
927abfc4461e7fd7 Ludovic Barre    2018-04-26  695  {
927abfc4461e7fd7 Ludovic Barre    2018-04-26  696  	struct stm32_exti_host_data *host_data = dm->host_data;
927abfc4461e7fd7 Ludovic Barre    2018-04-26  697  	struct stm32_exti_chip_data *chip_data;
c297493336b7bc0c Antonio Borneo   2022-06-06  698  	u8 desc_irq;
927abfc4461e7fd7 Ludovic Barre    2018-04-26  699  	struct irq_fwspec *fwspec = data;
927abfc4461e7fd7 Ludovic Barre    2018-04-26  700  	struct irq_fwspec p_fwspec;
927abfc4461e7fd7 Ludovic Barre    2018-04-26  701  	irq_hw_number_t hwirq;
9d6a5fe1757cbbd9 Alexandre Torgue 2020-07-17  702  	int bank;
ce4ef8f9f2abcf10 Antonio Borneo   2022-06-06  703  	u32 event_trg;
ce4ef8f9f2abcf10 Antonio Borneo   2022-06-06  704  	struct irq_chip *chip;
927abfc4461e7fd7 Ludovic Barre    2018-04-26  705  
927abfc4461e7fd7 Ludovic Barre    2018-04-26  706  	hwirq = fwspec->param[0];
c16ae609214e8356 Antonio Borneo   2022-06-06 @707  	if (hwirq >= host_data->drv_data->bank_nr * IRQS_PER_BANK)
                                                                     ^^^^^^^^^^^^^^^^^^^^^
derefernce

c16ae609214e8356 Antonio Borneo   2022-06-06  708  		return -EINVAL;
c16ae609214e8356 Antonio Borneo   2022-06-06  709  
927abfc4461e7fd7 Ludovic Barre    2018-04-26  710  	bank  = hwirq / IRQS_PER_BANK;
927abfc4461e7fd7 Ludovic Barre    2018-04-26  711  	chip_data = &host_data->chips_data[bank];
927abfc4461e7fd7 Ludovic Barre    2018-04-26  712  
ce4ef8f9f2abcf10 Antonio Borneo   2022-06-06  713  	event_trg = readl_relaxed(host_data->base + chip_data->reg_bank->trg_ofst);
ce4ef8f9f2abcf10 Antonio Borneo   2022-06-06  714  	chip = (event_trg & BIT(hwirq % IRQS_PER_BANK)) ?
ce4ef8f9f2abcf10 Antonio Borneo   2022-06-06  715  	       &stm32_exti_h_chip : &stm32_exti_h_chip_direct;
ce4ef8f9f2abcf10 Antonio Borneo   2022-06-06  716  
ce4ef8f9f2abcf10 Antonio Borneo   2022-06-06  717  	irq_domain_set_hwirq_and_chip(dm, virq, hwirq, chip, chip_data);
c297493336b7bc0c Antonio Borneo   2022-06-06  718  
c297493336b7bc0c Antonio Borneo   2022-06-06 @719  	if (!host_data->drv_data || !host_data->drv_data->desc_irqs)
                                                             ^^^^^^^^^^^^^^^^^^^
checked too late

c297493336b7bc0c Antonio Borneo   2022-06-06  720  		return -EINVAL;
c297493336b7bc0c Antonio Borneo   2022-06-06  721  
c297493336b7bc0c Antonio Borneo   2022-06-06  722  	desc_irq = host_data->drv_data->desc_irqs[hwirq];
c297493336b7bc0c Antonio Borneo   2022-06-06  723  	if (desc_irq != EXTI_INVALID_IRQ) {
927abfc4461e7fd7 Ludovic Barre    2018-04-26  724  		p_fwspec.fwnode = dm->parent->fwnode;
927abfc4461e7fd7 Ludovic Barre    2018-04-26  725  		p_fwspec.param_count = 3;
927abfc4461e7fd7 Ludovic Barre    2018-04-26  726  		p_fwspec.param[0] = GIC_SPI;
c297493336b7bc0c Antonio Borneo   2022-06-06  727  		p_fwspec.param[1] = desc_irq;
927abfc4461e7fd7 Ludovic Barre    2018-04-26  728  		p_fwspec.param[2] = IRQ_TYPE_LEVEL_HIGH;
927abfc4461e7fd7 Ludovic Barre    2018-04-26  729  
927abfc4461e7fd7 Ludovic Barre    2018-04-26  730  		return irq_domain_alloc_irqs_parent(dm, virq, 1, &p_fwspec);
927abfc4461e7fd7 Ludovic Barre    2018-04-26  731  	}
927abfc4461e7fd7 Ludovic Barre    2018-04-26  732  
927abfc4461e7fd7 Ludovic Barre    2018-04-26  733  	return 0;
927abfc4461e7fd7 Ludovic Barre    2018-04-26  734  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


             reply	other threads:[~2022-08-15  6:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15  6:51 Dan Carpenter [this message]
2022-08-17 12:57 ` [PATCH] irqchip/stm32-exti: Remove check on always false condition Antonio Borneo
2022-08-17 13:42   ` [irqchip: irq/irqchip-fixes] " irqchip-bot for Antonio Borneo
2022-09-13 12:53   ` irqchip-bot for Antonio Borneo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202208131739.gJvcs9ls-lkp@intel.com \
    --to=dan.carpenter@oracle.com \
    --cc=antonio.borneo@foss.st.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=maz@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®