public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Michael Grzeschik <m.grzeschik@pengutronix.de>,
	Shuah Khan <shuahkh@osg.samsung.com>
Subject: [PATCH 3.18 11/22] usb: usbip: set buffer pointers to NULL after free
Date: Thu, 13 Jul 2017 17:42:51 +0200	[thread overview]
Message-ID: <20170713153934.584117942@linuxfoundation.org> (raw)
In-Reply-To: <20170713153934.089183081@linuxfoundation.org>

3.18-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Michael Grzeschik <m.grzeschik@pengutronix.de>

commit b3b51417d0af63fb9a06662dc292200aed9ea53f upstream.

The usbip stack dynamically allocates the transfer_buffer and
setup_packet of each urb that got generated by the tcp to usb stub code.
As these pointers are always used only once we will set them to NULL
after use. This is done likewise to the free_urb code in vudc_dev.c.
This patch fixes double kfree situations where the usbip remote side
added the URB_FREE_BUFFER.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/usbip/stub_main.c |    4 ++++
 drivers/usb/usbip/stub_tx.c   |    4 ++++
 2 files changed, 8 insertions(+)

--- a/drivers/usb/usbip/stub_main.c
+++ b/drivers/usb/usbip/stub_main.c
@@ -262,7 +262,11 @@ void stub_device_cleanup_urbs(struct stu
 		kmem_cache_free(stub_priv_cache, priv);
 
 		kfree(urb->transfer_buffer);
+		urb->transfer_buffer = NULL;
+
 		kfree(urb->setup_packet);
+		urb->setup_packet = NULL;
+
 		usb_free_urb(urb);
 	}
 }
--- a/drivers/usb/usbip/stub_tx.c
+++ b/drivers/usb/usbip/stub_tx.c
@@ -28,7 +28,11 @@ static void stub_free_priv_and_urb(struc
 	struct urb *urb = priv->urb;
 
 	kfree(urb->setup_packet);
+	urb->setup_packet = NULL;
+
 	kfree(urb->transfer_buffer);
+	urb->transfer_buffer = NULL;
+
 	list_del(&priv->list);
 	kmem_cache_free(stub_priv_cache, priv);
 	usb_free_urb(urb);

  parent reply	other threads:[~2017-07-13 16:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-13 15:42 [PATCH 3.18 00/22] 3.18.61-stable review Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 01/22] driver core: platform: fix race condition with driver_override Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 02/22] MIPS: UAPI: Ignore __arch_swab{16,32,64} when using MIPS16 Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 04/22] bgmac: add check for oversized packets Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 06/22] usb: ehci-orion: fix probe for !GENERIC_PHY Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 07/22] tracing/kprobes: Allow to create probe with a module name starting with a digit Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 08/22] usb: dwc3: replace %p with %pK Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 09/22] USB: serial: cp210x: add ID for CEL EM3588 USB ZigBee stick Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 10/22] Add USB quirk for HVR-950q to avoid intermittent device resets Greg Kroah-Hartman
2017-07-13 15:42 ` Greg Kroah-Hartman [this message]
2017-07-13 15:42 ` [PATCH 3.18 12/22] usb: Fix typo in the definition of Endpoint[out]Request Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 14/22] pinctrl: sh-pfc: Update info pointer after SoC-specific init Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 17/22] KEYS: Fix an error code in request_master_key() Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 18/22] mqueue: fix a use-after-free in sys_mq_notify() Greg Kroah-Hartman
2017-07-13 15:42 ` [PATCH 3.18 19/22] md: fix super_offset endianness in super_1_rdev_size_change Greg Kroah-Hartman
2017-07-13 15:43 ` [PATCH 3.18 20/22] staging: vt6556: vnt_start Fix missing call to vnt_key_init_table Greg Kroah-Hartman
2017-07-13 15:43 ` [PATCH 3.18 21/22] staging: comedi: fix clean-up of comedi_class in comedi_init() Greg Kroah-Hartman
2017-07-13 15:43 ` [PATCH 3.18 22/22] [media] saa7134: fix warm Medion 7134 EEPROM read Greg Kroah-Hartman
2017-07-14  1:26 ` [PATCH 3.18 00/22] 3.18.61-stable review Guenter Roeck
2017-07-14  9:31   ` Greg Kroah-Hartman
2017-07-14 11:43     ` Amit Pundir

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=20170713153934.584117942@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.grzeschik@pengutronix.de \
    --cc=shuahkh@osg.samsung.com \
    --cc=stable@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