From: Guenter Roeck <linux@roeck-us.net>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: usb: typec: Fix unchecked return value
Date: Mon, 18 Mar 2019 15:37:43 -0700 [thread overview]
Message-ID: <20190318223743.GA18557@roeck-us.net> (raw)
On Mon, Mar 18, 2019 at 04:18:30PM -0500, Gustavo A. R. Silva wrote:
> Currently there is no check on platform_get_irq() return value
> in case it fails, hence never actually reporting any errors and
> causing unexpected behavior when using such value as argument
> for function regmap_irq_get_virq().
>
> Fix this by adding a proper check, a message error and return
> *irq* in case platform_get_irq() fails.
>
> Addresses-Coverity-ID: 1443899 ("Improper use of negative value")
> Fixes: d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/usb/typec/tcpm/wcove.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/wcove.c b/drivers/usb/typec/tcpm/wcove.c
> index 423208e19383..6770afd40765 100644
> --- a/drivers/usb/typec/tcpm/wcove.c
> +++ b/drivers/usb/typec/tcpm/wcove.c
> @@ -615,8 +615,13 @@ static int wcove_typec_probe(struct platform_device *pdev)
> wcove->dev = &pdev->dev;
> wcove->regmap = pmic->regmap;
>
> - irq = regmap_irq_get_virq(pmic->irq_chip_data_chgr,
> - platform_get_irq(pdev, 0));
> + irq = platform_get_irq(pdev, 0);
> + if (irq < 0) {
> + dev_err(&pdev->dev, "Failed to get IRQ: %d\n", irq);
> + return irq;
> + }
> +
> + irq = regmap_irq_get_virq(pmic->irq_chip_data_chgr, irq);
> if (irq < 0)
> return irq;
>
> --
> 2.21.0
>
next reply other threads:[~2019-03-18 22:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-18 22:37 Guenter Roeck [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-03-19 11:13 usb: typec: Fix unchecked return value Heikki Krogerus
2019-03-18 21:18 Gustavo A. R. Silva
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=20190318223743.GA18557@roeck-us.net \
--to=linux@roeck-us.net \
--cc=gregkh@linuxfoundation.org \
--cc=gustavo@embeddedor.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.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;
as well as URLs for NNTP newsgroup(s).