linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matwey V. Kornilov" <matwey@sai.msu.ru>
To: Bin Liu <b-liu@ti.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: matwey.kornilov@gmail.com,
	"Matwey V. Kornilov" <matwey@sai.msu.ru>,
	linux-usb@vger.kernel.org (open list:MUSB MULTIPOINT HIGH SPEED
	DUAL-ROLE CONTROLLER), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] usb: musb: Fix potential NULL dereference
Date: Wed, 23 Jan 2019 20:51:42 +0300	[thread overview]
Message-ID: <20190123175142.12604-1-matwey@sai.msu.ru> (raw)

We assign "urb->hcpriv = qh;" a few lines down. The valid qh for the urb is
hep->hcpriv in this code path.

Fixes: 714bc5ef3eda ("musb: potential use after free")
Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
---
 drivers/usb/musb/musb_host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index c6118a962d37..6f267716768e 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2336,7 +2336,7 @@ static int musb_urb_enqueue(
 		 * odd, rare, error prone, but legal.
 		 */
 		kfree(qh);
-		qh = NULL;
+		qh = hep->hcpriv;
 		ret = 0;
 	} else
 		ret = musb_schedule(musb, qh,
-- 
2.16.4


             reply	other threads:[~2019-01-23 18:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-23 17:51 Matwey V. Kornilov [this message]
2019-01-24 18:47 ` [PATCH] usb: musb: Fix potential NULL dereference Matwey V. Kornilov
2019-01-25 16:44   ` Bin Liu
2019-01-25 21:37     ` Alan Stern
2019-01-26  9:45       ` Matwey V. Kornilov
2019-02-18 16:44         ` [PATCH v2] usb: musb: Fix urb->hcpriv value Matwey V. Kornilov
2019-01-25 16:37 ` [PATCH] usb: musb: Fix potential NULL dereference Bin Liu

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=20190123175142.12604-1-matwey@sai.msu.ru \
    --to=matwey@sai.msu.ru \
    --cc=b-liu@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=matwey.kornilov@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).