linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu, Colin Ian King <colin.king@canonical.com>,
	Jia-Ju Bai <baijiaju1990@gmail.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: usb: u132-hcd: fix potential NULL pointer dereference
Date: Tue, 19 Mar 2019 14:56:09 +0100	[thread overview]
Message-ID: <20190319135609.GA16254@kroah.com> (raw)

On Thu, Mar 14, 2019 at 02:27:11AM -0500, Kangjie Lu wrote:
> In case create_singlethread_workqueue fails, the fix notifies
> callers the error to avoid potential NULL pointer dereferences.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>  drivers/usb/host/u132-hcd.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
> index 934584f0a20a..6d5b532b03f8 100644
> --- a/drivers/usb/host/u132-hcd.c
> +++ b/drivers/usb/host/u132-hcd.c
> @@ -3203,6 +3203,8 @@ static int __init u132_hcd_init(void)
>  		return -ENODEV;
>  	printk(KERN_INFO "driver %s\n", hcd_name);
>  	workqueue = create_singlethread_workqueue("u132");
> +	if (unlikely(!workqueue))

You only ever use unlikely/likely if you can actually measure the
difference with and without it.  For stuff like this, it is not needed
at all, and in fact, the compiler and CPU already know this type of
thing, so it is going to be faster without it.

And are you sure you properly unwound from anything that was
created/initialized above these lines?

thanks,

greg k-h

             reply	other threads:[~2019-03-19 13:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 13:56 Greg Kroah-Hartman [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-03-27 13:57 usb: u132-hcd: fix potential NULL pointer dereference Mukesh Ojha
2019-03-26  4:41 Greg Kroah-Hartman
2019-03-19 17:34 Kangjie Lu
2019-03-19 17:20 Kangjie Lu
2019-03-14  7:27 Kangjie Lu

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=20190319135609.GA16254@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=baijiaju1990@gmail.com \
    --cc=colin.king@canonical.com \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pakki001@umn.edu \
    /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).