mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ethan Zhao <ethan.kernel@gmail.com>
To: hans.verkuil@cisco.com, m.chehab@samsung.com, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, Ethan Zhao <ethan.kernel@gmail.com>
Subject: [PATCH] media: gspaca: check pointer against NULL before using it in create_urbs()
Date: Tue,  7 Jan 2014 17:56:02 +0800	[thread overview]
Message-ID: <1389088562-463-1-git-send-email-ethan.kernel@gmail.com> (raw)

function alt_xfer() may return NULL, should check its return value passed into
create_urbs() as parameter.

gspca_init_transfer()
{
... ...
ret = create_urbs(gspca_dev,alt_xfer(&intf->altsetting[alt], xfer));
... ...
}

Signed-off-by: Ethan Zhao <ethan.kernel@gmail.com>
---
 drivers/media/usb/gspca/gspca.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 048507b..eb45bc0 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -761,6 +761,8 @@ static int create_urbs(struct gspca_dev *gspca_dev,
 	struct urb *urb;
 	int n, nurbs, i, psize, npkt, bsize;
 
+	if (!ep)
+		return -EINVAL;
 	/* calculate the packet size and the number of packets */
 	psize = le16_to_cpu(ep->desc.wMaxPacketSize);
 
-- 
1.8.3.4 (Apple Git-47)


                 reply	other threads:[~2014-01-07  9:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1389088562-463-1-git-send-email-ethan.kernel@gmail.com \
    --to=ethan.kernel@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.chehab@samsung.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

Powered by JetHome