From patchwork Wed Sep 5 16:08:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10589169 X-Patchwork-Delegate: bhelgaas@google.com 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 DDBE05A4 for ; Wed, 5 Sep 2018 16:08:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C890A2894D for ; Wed, 5 Sep 2018 16:08:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B91D22A03B; Wed, 5 Sep 2018 16:08:09 +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,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 58BFA2894D for ; Wed, 5 Sep 2018 16:08:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727234AbeIEUi7 (ORCPT ); Wed, 5 Sep 2018 16:38:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:54778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726189AbeIEUi7 (ORCPT ); Wed, 5 Sep 2018 16:38:59 -0400 Received: from sinanubuntu1604.mkjiurmyylmellclgttazegk5f.bx.internal.cloudapp.net (unknown [40.76.78.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A86202075C; Wed, 5 Sep 2018 16:08:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536163688; bh=MMTHTod9nNrI4+BczcD5SoIhghhTn7UMvpLXtGTqY1o=; h=From:To:Cc:Subject:Date:From; b=B6Mq+5370ODf2Z2FSi7yru2kPHfZZ7c6CKAyq4EO4qtSfkQnPeH/IjzSYBum7VLon a7s+qu1jvEFYJ6BwveOVQmEmQrDMlM1/giua7ZC0LmIOkKmPLuegyOtjiByqb/uf/o 0DOHCROtXdfI7v75+0lvuG4UiY9EyBsmPno7jriw= From: Sinan Kaya To: linux-pci@vger.kernel.org Cc: Dennis Dalessandro , Sinan Kaya , Bjorn Helgaas Subject: [PATCH for-rc v2 1/3] PCI: Fix faulty logic in pci_reset_bus() Date: Wed, 5 Sep 2018 16:08:03 +0000 Message-Id: <20180905160805.5680-1-okaya@kernel.org> X-Mailer: git-send-email 2.18.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dennis Dalessandro The pci_rest_bus() function calls into pci_probe_reset_slot() to determine whether to call the slot or bus reset. The check has faulty logic in that it does not account for pci_probe_reset_slot() being able to return an errno. Fix by only calling the slot reset when the function returns 0. Treat < 1 and > 1 the same. Cc: Sinan Kaya Fixes: 811c5cb37df4 ("PCI: Unify try slot and bus reset API") Reviewed-by: Michael J. Ruhl Signed-off-by: Dennis Dalessandro --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 29ff9619b5fa..30b260332a10 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5200,7 +5200,7 @@ static int __pci_reset_bus(struct pci_bus *bus) */ int pci_reset_bus(struct pci_dev *pdev) { - return pci_probe_reset_slot(pdev->slot) ? + return (!pci_probe_reset_slot(pdev->slot)) ? __pci_reset_slot(pdev->slot) : __pci_reset_bus(pdev->bus); } EXPORT_SYMBOL_GPL(pci_reset_bus);