usb: xhci: Fix potential memory leak in xhci_disable_slot()
authorLu Baolu <baolu.lu@linux.intel.com>
Thu, 5 Oct 2017 08:21:41 +0000 (11:21 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Mar 2018 16:24:50 +0000 (18:24 +0200)
commitd6e6e57e60457ad1a9fa4dd83f1d456020f7b5c7
treed29008c4f1ca5ac8ea73fa5eb72185ba8c54766b
parent4208d820ed232ed0df7ac3292ff8bcd1545d0093
usb: xhci: Fix potential memory leak in xhci_disable_slot()

commit cd3f1790b006d91786728c20a01da21ee277aff1 upstream.

xhci_disable_slot() allows the invoker to pass a command pointer
as paramenter. Otherwise, it will allocate one. This will cause
memory leak when a command structure was allocated inside of this
function while queuing command trb fails. Another problem comes up
when the invoker passed a command pointer, but xhci_disable_slot()
frees it when it detects a dead host.

This patch fixes these two problems by removing the command parameter
from xhci_disable_slot().

Fixes: f9e609b82479 ("usb: xhci: Add helper function xhci_disable_slot().")
Cc: Guoqing Zhang <guoqing.zhang@intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-hub.c
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h