diff options
author | Nobuo Iwata <nobuo.iwata@fujixerox.co.jp> | 2016-10-12 23:49:02 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-11-07 04:19:49 -0500 |
commit | d79cda045e3bacb7e754a5324cd3d4ce80708eb1 (patch) | |
tree | 6ecd81986ce1dd6925946490b8604503afefa50f | |
parent | 220c61b6f73a1d6f28591aeedff51a668068361b (diff) |
usbip: fix possibility of dereference by NULLL pointer in vhci_hcd.c
This patch fixes possibility of dereference by NULLL pointer in "[PATCH
v5 1/3] usbip: vhci extension: modifications to vhci driver" which has
been merged to 4.9-rc1. It occurs when a URB with pointer to invalid
USB/IP device is enqueued in race condition against detach operation.
A pointer was passed to vdev_to_vhci() before NULL check.
In vdev_to_vhci(), there's a dereference by the pointer.
This patch moves vdev_to_vhci() after NULL check of the pointer.
Signed-off-by: Nobuo Iwata <nobuo.iwata@fujixerox.co.jp>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/usbip/vhci_hcd.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index 03eccf29ace0..c4724fb3a691 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c | |||
@@ -460,13 +460,14 @@ static void vhci_tx_urb(struct urb *urb) | |||
460 | { | 460 | { |
461 | struct vhci_device *vdev = get_vdev(urb->dev); | 461 | struct vhci_device *vdev = get_vdev(urb->dev); |
462 | struct vhci_priv *priv; | 462 | struct vhci_priv *priv; |
463 | struct vhci_hcd *vhci = vdev_to_vhci(vdev); | 463 | struct vhci_hcd *vhci; |
464 | unsigned long flags; | 464 | unsigned long flags; |
465 | 465 | ||
466 | if (!vdev) { | 466 | if (!vdev) { |
467 | pr_err("could not get virtual device"); | 467 | pr_err("could not get virtual device"); |
468 | return; | 468 | return; |
469 | } | 469 | } |
470 | vhci = vdev_to_vhci(vdev); | ||
470 | 471 | ||
471 | priv = kzalloc(sizeof(struct vhci_priv), GFP_ATOMIC); | 472 | priv = kzalloc(sizeof(struct vhci_priv), GFP_ATOMIC); |
472 | if (!priv) { | 473 | if (!priv) { |