Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934300AbcKILOu (ORCPT ); Wed, 9 Nov 2016 06:14:50 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:55548 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934214AbcKILLC (ORCPT ); Wed, 9 Nov 2016 06:11:02 -0500 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Stefan Wahren , Peter Chen Subject: [PATCH 4.8 129/138] usb: chipidea: host: fix NULL ptr dereference during shutdown Date: Wed, 9 Nov 2016 11:46:52 +0100 Message-Id: <20161109102850.899851377@linuxfoundation.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161109102844.808685475@linuxfoundation.org> References: <20161109102844.808685475@linuxfoundation.org> User-Agent: quilt/0.64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1318 Lines: 37 4.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Wahren commit 991d5add50a5bb6ab8f12f2129f5c7487f6baaf6 upstream. After commit b09b5224fe86 ("usb: chipidea: implement platform shutdown callback") and commit 43a404577a93 ("usb: chipidea: host: set host to be null after hcd is freed") a NULL pointer dereference is caused on i.MX23 during shutdown. So ensure that role is set to CI_ROLE_END and we finish interrupt handling before the hcd is deallocated. This avoids the NULL pointer dereference. Suggested-by: Alan Stern Signed-off-by: Stefan Wahren Fixes: b09b5224fe86 ("usb: chipidea: implement platform shutdown callback") Signed-off-by: Peter Chen Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/host.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -185,6 +185,8 @@ static void host_stop(struct ci_hdrc *ci if (hcd) { usb_remove_hcd(hcd); + ci->role = CI_ROLE_END; + synchronize_irq(ci->irq); usb_put_hcd(hcd); if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) && (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON))