linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Valentina Manea <valentina.manea.m@gmail.com>,
	Shuah Khan <shuah.kh@samsung.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH] usb: usbip: fix null pointer dereference
Date: Thu,  2 Jun 2016 18:52:33 +0530	[thread overview]
Message-ID: <1464873753-11456-1-git-send-email-sudipm.mukherjee@gmail.com> (raw)

We have been dereferencing udc before checking it. Lets use it after it
has been checked.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
---
 drivers/usb/usbip/vudc_sysfs.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
index 99397fa..0ba6a06 100644
--- a/drivers/usb/usbip/vudc_sysfs.c
+++ b/drivers/usb/usbip/vudc_sysfs.c
@@ -35,14 +35,17 @@
 int get_gadget_descs(struct vudc *udc)
 {
 	struct vrequest *usb_req;
-	struct vep *ep0 = to_vep(udc->gadget.ep0);
-	struct usb_device_descriptor *ddesc = &udc->dev_desc;
+	struct vep *ep0;
+	struct usb_device_descriptor *ddesc;
 	struct usb_ctrlrequest req;
 	int ret;
 
 	if (!udc || !udc->driver || !udc->pullup)
 		return -EINVAL;
 
+	ep0 = to_vep(udc->gadget.ep0);
+	ddesc = &udc->dev_desc;
+
 	req.bRequestType = USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
 	req.bRequest = USB_REQ_GET_DESCRIPTOR;
 	req.wValue = cpu_to_le16(USB_DT_DEVICE << 8);
-- 
1.9.1

             reply	other threads:[~2016-06-02 17:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02 13:22 Sudip Mukherjee [this message]
2016-06-03  8:29 ` [PATCH] usb: usbip: fix null pointer dereference Krzysztof Opasiak
2016-06-03 14:21   ` Alan Stern
2016-06-05 17:54   ` Sudip Mukherjee
2016-06-06  8:20     ` Krzysztof Opasiak
2016-06-06  8:47       ` Sudip Mukherjee

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=1464873753-11456-1-git-send-email-sudipm.mukherjee@gmail.com \
    --to=sudipm.mukherjee@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shuah.kh@samsung.com \
    --cc=valentina.manea.m@gmail.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;
as well as URLs for NNTP newsgroup(s).