From patchwork Fri Sep 21 02:53:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 972817 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42GdG41KGZz9sDK for ; Fri, 21 Sep 2018 12:43:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388841AbeIUIac (ORCPT ); Fri, 21 Sep 2018 04:30:32 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:47745 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726103AbeIUIab (ORCPT ); Fri, 21 Sep 2018 04:30:31 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id F090333123DED; Fri, 21 Sep 2018 10:43:49 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.399.0; Fri, 21 Sep 2018 10:43:44 +0800 From: Wei Yongjun To: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Lorenzo Pieralisi" , Bjorn Helgaas CC: Wei Yongjun , , , , Subject: [PATCH RESEND] PCI: hv: Fix return value check in hv_pci_assign_slots() Date: Fri, 21 Sep 2018 02:53:17 +0000 Message-ID: <1537498397-191756-1-git-send-email-weiyongjun1@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537425631-28460-1-git-send-email-weiyongjun1@huawei.com> References: <1537425631-28460-1-git-send-email-weiyongjun1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In case of error, the function pci_create_slot() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Fixes: a15f2c08c708 ("PCI: hv: support reporting serial number as slot information") Signed-off-by: Wei Yongjun --- Since the orig patch is merged from net tree, cc netdev@vger.kernel.org --- drivers/pci/controller/pci-hyperv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index ee80e79..9ba4d12 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1484,8 +1484,10 @@ static void hv_pci_assign_slots(struct hv_pcibus_device *hbus) snprintf(name, SLOT_NAME_SIZE, "%u", hpdev->desc.ser); hpdev->pci_slot = pci_create_slot(hbus->pci_bus, slot_nr, name, NULL); - if (!hpdev->pci_slot) + if (IS_ERR(hpdev->pci_slot)) { pr_warn("pci_create slot %s failed\n", name); + hpdev->pci_slot = NULL; + } } }