From: Dan Carpenter <dan.carpenter@oracle.com>
To: robert.jarzmik@free.fr
Cc: linux-mmc@vger.kernel.org
Subject: [bug report] mmc: pxamci: fix card detect with slot-gpio API
Date: Wed, 13 Jul 2016 23:14:07 +0300 [thread overview]
Message-ID: <20160713201407.GA19098@mwanda> (raw)
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
next reply other threads:[~2016-07-13 20:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-13 20:14 Dan Carpenter [this message]
2016-07-14 13:30 ` [bug report] mmc: pxamci: fix card detect with slot-gpio API Robert Jarzmik
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=20160713201407.GA19098@mwanda \
--to=dan.carpenter@oracle.com \
--cc=linux-mmc@vger.kernel.org \
--cc=robert.jarzmik@free.fr \
/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;
as well as URLs for NNTP newsgroup(s).