From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751795AbcLEOHf (ORCPT ); Mon, 5 Dec 2016 09:07:35 -0500 Received: from mga07.intel.com ([134.134.136.100]:31878 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751567AbcLEOHc (ORCPT ); Mon, 5 Dec 2016 09:07:32 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,747,1477983600"; d="scan'208";a="1094783328" Subject: Re: [PATCH 1/2] usb: host: xhci: Fix possible wild pointer when handling abort command To: Baolin Wang , mathias.nyman@intel.com, gregkh@linuxfoundation.org References: Cc: baolu.lu@linux.intel.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, broonie@kernel.org From: Mathias Nyman Message-ID: <584574C7.3020307@linux.intel.com> Date: Mon, 5 Dec 2016 16:08:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05.12.2016 09:51, Baolin Wang wrote: > When current command was supposed to be aborted, host will free the command > in handle_cmd_completion() function. But it might be still referenced by > xhci->current_cmd, which need to set NULL. > > Signed-off-by: Baolin Wang > --- > This patch is based on Lu Baolu's new fix patch: > usb: xhci: fix possible wild pointer > https://www.spinics.net/lists/linux-usb/msg150219.html > --- > drivers/usb/host/xhci-ring.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c > index 62dd1c7..9965a4c 100644 > --- a/drivers/usb/host/xhci-ring.c > +++ b/drivers/usb/host/xhci-ring.c > @@ -1362,8 +1362,11 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, > */ > if (cmd_comp_code == COMP_CMD_ABORT) { > xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; > - if (cmd->status == COMP_CMD_ABORT) > + if (cmd->status == COMP_CMD_ABORT) { > + if (xhci->current_cmd == cmd) > + xhci->current_cmd = NULL; > goto event_handled; > + } > } > > cmd_type = TRB_FIELD_TO_TYPE(le32_to_cpu(cmd_trb->generic.field[3])); > True, thanks -Mathias