From patchwork Fri Aug 14 12:13:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Temerkhanov X-Patchwork-Id: 507362 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D8B72140291 for ; Fri, 14 Aug 2015 22:07:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=M2P+7YzL; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7DE654B6EA; Fri, 14 Aug 2015 14:07:33 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2_mkycYqK0HY; Fri, 14 Aug 2015 14:07:33 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A6CEB4B6D5; Fri, 14 Aug 2015 14:07:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 608EF4B6D5 for ; Fri, 14 Aug 2015 14:07:30 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UV3qOLxGrc1c for ; Fri, 14 Aug 2015 14:07:30 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-la0-f67.google.com (mail-la0-f67.google.com [209.85.215.67]) by theia.denx.de (Postfix) with ESMTPS id 1C52D4B617 for ; Fri, 14 Aug 2015 14:07:25 +0200 (CEST) Received: by lahi9 with SMTP id i9so4021845lah.1 for ; Fri, 14 Aug 2015 05:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=g7lKYaEc9PAzz63KO/aJ/fIU4S/xVI/Bf8E9gtL/xAA=; b=M2P+7YzLSReF/lUlw1/e/eobbmM4fO0VCv9R+muJPAxyuJojiUyXe4qIgC9+Jbgg4K +sMxU6NcHJgzJOeH3+L0gY4icqGvRWt0xku9oORJSmqrxODIhp88ZeuRnmm3Z+L6yNc5 Xg8pdTDW3WtBkRVUZ8ltFxG/wmF7OnvZ5zjZ2kwbgvhOg334HJx2mBD5FcZDlqtdOwIP /xA0y5a3eDBcu0KLVi2WoQM2fUtADBQ9D2CVzyWDFPa77Kpd22o6R0LeK7Vds93t1u6m Ukea0EWSMndwT2Gld1gVhjTev8c/AeKBXCXbreKaBilVJQ4LSPL0giMT3h5N5o+rP8Wy xn5w== X-Received: by 10.152.21.227 with SMTP id y3mr43551185lae.24.1439554045103; Fri, 14 Aug 2015 05:07:25 -0700 (PDT) Received: from snickers.office.auriga.msk ([81.19.133.99]) by smtp.gmail.com with ESMTPSA id o7sm1412517lbp.9.2015.08.14.05.07.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Aug 2015 05:07:24 -0700 (PDT) From: Sergey Temerkhanov To: u-boot@lists.denx.de Date: Fri, 14 Aug 2015 15:13:06 +0300 Message-Id: <1439554386-9406-1-git-send-email-s.temerkhanov@gmail.com> X-Mailer: git-send-email 2.2.0 Cc: Marek Vasut , Tom Rini , Masahiro Yamada , Radha Mohan Chintakuntla Subject: [U-Boot] [PATCH] usb: xhci: Fix a potential NULL pointer dereference X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch fixes a potential NULL pointer dereference arising on non-present/non-initialized xHCI controllers Signed-off-by: Sergey Temerkhanov Signed-off-by: Radha Mohan Chintakuntla --- drivers/usb/host/xhci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 0b09643..a6c6659 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -199,7 +199,7 @@ int xhci_reset(struct xhci_hcor *hcor) int ret; /* Halting the Host first */ - debug("// Halt the HC\n"); + debug("// Halt the HC: %p\n", hcor); state = xhci_readl(&hcor->or_usbsts) & STS_HALT; if (!state) { cmd = xhci_readl(&hcor->or_usbcmd); @@ -1093,9 +1093,11 @@ int usb_lowlevel_stop(int index) { struct xhci_ctrl *ctrl = (xhcic + index); - xhci_lowlevel_stop(ctrl); - xhci_hcd_stop(index); - xhci_cleanup(ctrl); + if (ctrl->hcor) { + xhci_lowlevel_stop(ctrl); + xhci_hcd_stop(index); + xhci_cleanup(ctrl); + } return 0; }