All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] mmc: pxamci: fix card detect with slot-gpio API
@ 2016-07-13 20:14 Dan Carpenter
  2016-07-14 13:30 ` Robert Jarzmik
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-07-13 20:14 UTC (permalink / raw)
  To: robert.jarzmik; +Cc: linux-mmc

Hello Robert Jarzmik,

The patch fd546ee6a7dc: "mmc: pxamci: fix card detect with slot-gpio
API" from Sep 26, 2015, leads to the following static checker warning:

	drivers/mmc/host/pxamci.c:809 pxamci_probe()
	warn: variable dereferenced before check 'host->pdata' (see line 798)

drivers/mmc/host/pxamci.c
  775  
   776          if (host->pdata) {
                    ^^^^^^^^^^^
We check it here.

   777                  gpio_cd = host->pdata->gpio_card_detect;
   778                  gpio_ro = host->pdata->gpio_card_ro;
   779                  gpio_power = host->pdata->gpio_power;
   780          }
   781          if (gpio_is_valid(gpio_power)) {
   782                  ret = devm_gpio_request(&pdev->dev, gpio_power,
   783                                          "mmc card power");
   784                  if (ret) {
   785                          dev_err(&pdev->dev, "Failed requesting gpio_power %d\n",
   786                                  gpio_power);
   787                          goto out;
   788                  }
   789                  gpio_direction_output(gpio_power,
   790                                        host->pdata->gpio_power_invert);
   791          }
   792          if (gpio_is_valid(gpio_ro))

If gpio_is_valid is valid that implies "host->pdata" is non-NULL.


   793                  ret = mmc_gpio_request_ro(mmc, gpio_ro);
   794          if (ret) {
                    ^^^
If host->pdata is NULL that implies ret is zero.  If it's non-NULL then
ret could be zero or negative.

   795                  dev_err(&pdev->dev, "Failed requesting gpio_ro %d\n", gpio_ro);
   796                  goto out;
   797          } else {
   798                  mmc->caps2 |= host->pdata->gpio_card_ro_invert ?
                                      ^^^^^^^^^^^^^
Potential oops.

   799                          0 : MMC_CAP2_RO_ACTIVE_HIGH;
   800          }
   801  
   802          if (gpio_is_valid(gpio_cd))
   803                  ret = mmc_gpio_request_cd(mmc, gpio_cd, 0);
   804          if (ret) {
   805                  dev_err(&pdev->dev, "Failed requesting gpio_cd %d\n", gpio_cd);
   806                  goto out;
   807          }
   808  
   809          if (host->pdata && host->pdata->init)
                    ^^^^^^^^^^^
There are no possible path where we can reach this check with
host->pdata is NULL and we haven't oopsed.

   810                  host->pdata->init(&pdev->dev, pxamci_detect_irq, mmc);
   811  

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] mmc: pxamci: fix card detect with slot-gpio API
  2016-07-13 20:14 [bug report] mmc: pxamci: fix card detect with slot-gpio API Dan Carpenter
@ 2016-07-14 13:30 ` Robert Jarzmik
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Jarzmik @ 2016-07-14 13:30 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-mmc

Dan Carpenter <dan.carpenter@oracle.com> writes:

> Hello Robert Jarzmik,
>
> The patch fd546ee6a7dc: "mmc: pxamci: fix card detect with slot-gpio
> API" from Sep 26, 2015, leads to the following static checker warning:

Hi Dan,

I'm taking that fix, thanks for the report.

By the way, if your mails are "auto-generated", could you amend the generator to
use the format "commit <12+ chars of sha1> ("<title line>")" instead of "patch
xxx", so that we(I) can quote you directly in the commit message ?

Cheers.

--
Robert

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-14 13:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-13 20:14 [bug report] mmc: pxamci: fix card detect with slot-gpio API Dan Carpenter
2016-07-14 13:30 ` Robert Jarzmik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.