mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arvind Yadav <arvind.yadav.cs@gmail.com>
To: balbi@kernel.org, gregkh@linuxfoundation.org
Cc: k.opasiak@samsung.com, mina86@mina86.com,
	i.kotrasinsk@samsung.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [v1] usb:gadget:legacy:nokia :- Check for NULL in nokia_bind_config
Date: Thu,  8 Dec 2016 22:02:13 +0530	[thread overview]
Message-ID: <1481214733-8702-1-git-send-email-arvind.yadav.cs@gmail.com> (raw)

Here, f_acm,f_ecm and f_msg needs to be checked for being NULL
in nokia_bind_config() before calling usb_add_function(),
otherwise kernel can run into a NULL-pointer dereference.

f_phonet, f_obex1 and f_obex2 need to be checked for NULL
in nokia_bind_config() to print proper debug information.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/usb/gadget/legacy/nokia.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/gadget/legacy/nokia.c
index b1e535f..d3ba286 100644
--- a/drivers/usb/gadget/legacy/nokia.c
+++ b/drivers/usb/gadget/legacy/nokia.c
@@ -159,36 +159,36 @@ static int nokia_bind_config(struct usb_configuration *c)
 
 	if (!IS_ERR(fi_phonet)) {
 		f_phonet = usb_get_function(fi_phonet);
-		if (IS_ERR(f_phonet))
+		if (IS_ERR_OR_NULL(f_phonet))
 			pr_debug("could not get phonet function\n");
 	}
 
 	if (!IS_ERR(fi_obex1)) {
 		f_obex1 = usb_get_function(fi_obex1);
-		if (IS_ERR(f_obex1))
+		if (IS_ERR_OR_NULL(f_obex1))
 			pr_debug("could not get obex function 0\n");
 	}
 
 	if (!IS_ERR(fi_obex2)) {
 		f_obex2 = usb_get_function(fi_obex2);
-		if (IS_ERR(f_obex2))
+		if (IS_ERR_OR_NULL(f_obex2))
 			pr_debug("could not get obex function 1\n");
 	}
 
 	f_acm = usb_get_function(fi_acm);
-	if (IS_ERR(f_acm)) {
+	if (IS_ERR_OR_NULL(f_acm)) {
 		status = PTR_ERR(f_acm);
 		goto err_get_acm;
 	}
 
 	f_ecm = usb_get_function(fi_ecm);
-	if (IS_ERR(f_ecm)) {
+	if (IS_ERR_OR_NULL(f_ecm)) {
 		status = PTR_ERR(f_ecm);
 		goto err_get_ecm;
 	}
 
 	f_msg = usb_get_function(fi_msg);
-	if (IS_ERR(f_msg)) {
+	if (IS_ERR_OR_NULL(f_msg)) {
 		status = PTR_ERR(f_msg);
 		goto err_get_msg;
 	}
-- 
2.7.4

             reply	other threads:[~2016-12-08 16:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-08 16:32 Arvind Yadav [this message]
2016-12-09 14:59 ` Michal Nazarewicz

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=1481214733-8702-1-git-send-email-arvind.yadav.cs@gmail.com \
    --to=arvind.yadav.cs@gmail.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=i.kotrasinsk@samsung.com \
    --cc=k.opasiak@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mina86@mina86.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