linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@freescale.com>
To: Badhri Jagan Sridharan <badhri@google.com>
Cc: Felipe Balbi <balbi@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: gadget: Check for NULL pointer in disconnect
Date: Sun, 22 Mar 2015 15:43:54 +0800	[thread overview]
Message-ID: <20150322074353.GA25278@shlinux2> (raw)
In-Reply-To: <1426894852-4256-1-git-send-email-Badhri@google.com>

On Fri, Mar 20, 2015 at 04:40:52PM -0700, Badhri Jagan Sridharan wrote:
> Added a safety net to make sure that
> composite_disconnect does not end up disconneting
> a NULL device. Prevents NULL pointer crash.
> 
> Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
> ---
>  drivers/usb/gadget/composite.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 13adfd1..90b37bd 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -1823,6 +1823,11 @@ void composite_disconnect(struct usb_gadget *gadget)
>  	struct usb_composite_dev	*cdev = get_gadget_data(gadget);
>  	unsigned long			flags;
>  
> +	if (!cdev) {
> +		WARN(1, "Trying to disconnect a NULL composite device\n");
> +		return;
> +	}
> +

Do you really see some udc drivers call it after composite_unbind is
called? If it is, you may add dump_stack() to track that error.

Besides this, function suspended_show is needed to add cdev NULL pointer
checking.

>  	/* REVISIT:  should we have config and device level
>  	 * disconnect callbacks?
>  	 */
> -- 
> 2.2.0.rc0.207.ga3a616c
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 

Best Regards,
Peter Chen

  reply	other threads:[~2015-03-22  7:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 23:40 [PATCH] usb: gadget: Check for NULL pointer in disconnect Badhri Jagan Sridharan
2015-03-22  7:43 ` Peter Chen [this message]
2015-03-23 23:00   ` Badhri Jagan Sridharan
2015-03-24  8:39     ` Peter Chen
2015-03-24 16:30     ` Felipe Balbi

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=20150322074353.GA25278@shlinux2 \
    --to=peter.chen@freescale.com \
    --cc=badhri@google.com \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --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).