From patchwork Wed Feb 20 13:48:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10822159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ADD1113B5 for ; Wed, 20 Feb 2019 13:48:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 962982E246 for ; Wed, 20 Feb 2019 13:48:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A69A2E28A; Wed, 20 Feb 2019 13:48:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E8E92E246 for ; Wed, 20 Feb 2019 13:48:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725836AbfBTNsq (ORCPT ); Wed, 20 Feb 2019 08:48:46 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36756 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725801AbfBTNsp (ORCPT ); Wed, 20 Feb 2019 08:48:45 -0500 Received: by mail-wm1-f66.google.com with SMTP id j125so6521103wmj.1; Wed, 20 Feb 2019 05:48:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=g4/1vAWv0PYcH8MAfmLwsmLeWcHepjkaHV3hoseB+BE=; b=KoMY/EmLUmceT01mlg7hAWq84z2cKfsiYXroWLZvIYq+B9EFSE9AgZL7YuC/sjpXLd KKI88y89h1LR+6D9mzGKk6O9LjRwQwqwMpyYlbWQ6yuBpHRStfL1hLmbAXOA57HS7fer 5Wq65xWOUNCCujhe4dURLu4qCKf4DznCWsOpd7osnquHcBQ5KLbH4HEg5YT3jHTQCSLi ++SJnzzkdaOTi7nJ9iNCoZiI10UDdrp7gP8AK5j9gNzyL4PB9jyVIYw1QIkeOTLjlsN8 sUKJJWPepKt+40ZFdVCPMRNUMqzdGO4T7W22ormz9aGsNT0qrnCIKwkMjDf/9tYOdZ30 YbEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=g4/1vAWv0PYcH8MAfmLwsmLeWcHepjkaHV3hoseB+BE=; b=BfH1t5RiKgxAO2NsREFfacblGQGb/TnIQEenQ0i7qMi9hA1XlLxUuYuIGrbLpdprnz NbVS8awKWpyx2cE/Kf3Amwa1CVk0vJ38BAVyBy/esQcQU3K+/IkNl9lL8NvOKEk1HGhF 52xh9AjHaQ9H35uN9l1O2jNfDPQbt3iNIC/rzk/hUyjh7BUuLVhRm/eQSaqs2LdBwU+A Fi3E1kH/EZYNXmnwBwt2T+gR8VaiMR1t9nBHU/wsnwJuiryv0pqTPKmF+98lGopw8SVi SGGeynGtqUF5pTwWdd9a+r5llH60NbL+wNXxjbF2aTQS1JaPff+SR5SaLcQhlnkQ9SAR E9pQ== X-Gm-Message-State: AHQUAub/JROGycRCxnNyNtsHDJmY+YGpBRf3OMlUh+0pGivwa/bQ7wMl GfK/QIU6IG6MfHchy+r5ScEjqgBb X-Google-Smtp-Source: AHgI3IYz+ka/fK63/UKEEa2EbbviGt3viqu6A4nY5MHinFzROlw0l9yyF06BEldhxeWP7+4SD02Zow== X-Received: by 2002:a1c:d147:: with SMTP id i68mr6996991wmg.41.1550670523523; Wed, 20 Feb 2019 05:48:43 -0800 (PST) Received: from localhost (pD9E51D2D.dip0.t-ipconnect.de. [217.229.29.45]) by smtp.gmail.com with ESMTPSA id m4sm6214812wmi.3.2019.02.20.05.48.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Feb 2019 05:48:42 -0800 (PST) From: Thierry Reding To: Greg Kroah-Hartman , Mathias Nyman Cc: Jonathan Hunter , linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH] xhci: tegra: Prevent error pointer dereference Date: Wed, 20 Feb 2019 14:48:41 +0100 Message-Id: <20190220134841.7642-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding During initialization, the host and super-speed power domains will contain an ERR_PTR() encoded error code rather than being NULL. To avoid a crash, use a !IS_ERR_OR_NULL() condition during cleanup. Signed-off-by: Thierry Reding Reviewed-by: Jon Hunter Acked-by: Mathias Nyman --- drivers/usb/host/xhci-tegra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 938ff06c0349..efb0cad8710e 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -941,9 +941,9 @@ static void tegra_xusb_powerdomain_remove(struct device *dev, device_link_del(tegra->genpd_dl_ss); if (tegra->genpd_dl_host) device_link_del(tegra->genpd_dl_host); - if (tegra->genpd_dev_ss) + if (!IS_ERR_OR_NULL(tegra->genpd_dev_ss)) dev_pm_domain_detach(tegra->genpd_dev_ss, true); - if (tegra->genpd_dev_host) + if (!IS_ERR_OR_NULL(tegra->genpd_dev_host)) dev_pm_domain_detach(tegra->genpd_dev_host, true); }