public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
To: Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jussi Kivilinna <jussi.kivilinna@haltian.com>,
	Tim Harvey <tharvey@gateworks.com>,
	Colin Ian King <colin.king@canonical.com>,
	Raz Manor <Raz.Manor@valens.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <garsilva@embeddedor.com>,
	Peter Senna Tschudin <peter.senna@gmail.com>
Subject: [PATCH] usb: gadget: udc: add null check before pointer dereference
Date: Mon, 1 May 2017 22:38:46 -0500	[thread overview]
Message-ID: <20170502033846.GA20518@embeddedgus> (raw)

Add null check before dereferencing dev->regs pointer inside
net2280_led_shutdown() function.

Addresses-Coverity-ID: 101783
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/usb/gadget/udc/net2280.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 3828c2e..1898a4b 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -3573,7 +3573,11 @@ static void net2280_remove(struct pci_dev *pdev)
 	BUG_ON(dev->driver);
 
 	/* then clean up the resources we allocated during probe() */
-	net2280_led_shutdown(dev);
+
+	if (dev->regs) {
+		net2280_led_shutdown(dev);
+		iounmap(dev->regs);
+	}
 	if (dev->requests) {
 		int		i;
 		for (i = 1; i < 5; i++) {
@@ -3588,8 +3592,6 @@ static void net2280_remove(struct pci_dev *pdev)
 		free_irq(pdev->irq, dev);
 	if (dev->quirks & PLX_PCIE)
 		pci_disable_msi(pdev);
-	if (dev->regs)
-		iounmap(dev->regs);
 	if (dev->region)
 		release_mem_region(pci_resource_start(pdev, 0),
 				pci_resource_len(pdev, 0));
-- 
2.5.0

             reply	other threads:[~2017-05-02  4:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02  3:38 Gustavo A. R. Silva [this message]
2017-05-02 14:31 ` [PATCH] usb: gadget: udc: add null check before pointer dereference Alan Stern
2017-05-02 15:29   ` Gustavo A. R. Silva
2017-05-02 16:37     ` [PATCH v2] " Gustavo A. R. Silva
2017-05-02 18:45       ` Alan Stern

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=20170502033846.GA20518@embeddedgus \
    --to=garsilva@embeddedor.com \
    --cc=Raz.Manor@valens.com \
    --cc=balbi@kernel.org \
    --cc=colin.king@canonical.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jussi.kivilinna@haltian.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.senna@gmail.com \
    --cc=tharvey@gateworks.com \
    /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