From patchwork Tue Dec 17 16:48:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Upinder Malhi (umalhi)" X-Patchwork-Id: 3362861 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4473DC0D4A for ; Tue, 17 Dec 2013 16:58:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 332D520381 for ; Tue, 17 Dec 2013 16:58:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB58E20382 for ; Tue, 17 Dec 2013 16:58:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754913Ab3LQQ6b (ORCPT ); Tue, 17 Dec 2013 11:58:31 -0500 Received: from mtv-iport-1.cisco.com ([173.36.130.12]:63316 "EHLO mtv-iport-1.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754872Ab3LQQ6a (ORCPT ); Tue, 17 Dec 2013 11:58:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2055; q=dns/txt; s=iport; t=1387299510; x=1388509110; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ITukzMsNzV1CTVJ01umrOhyyBiq3MpCES6m6SJaWjUE=; b=Di/OUsL8q1O3y0gyNNgQTuvMEdbsB5PkEJgIRpS1ZQb/Z1GHFTh0OWFi mHGQKgCWa4nbFp15IJnr6JkI/5Sm2hVP7X1athaY9hAMO8m6ZI7otmU8B G+xQwDKFYRaLvg89khb2RoA4RRXvcJ3B7Pt44QIOlKQAvUlk1u8sz9CF7 c=; X-IronPort-AV: E=Sophos;i="4.95,502,1384300800"; d="scan'208";a="97555792" Received: from mtv-core-3.cisco.com ([171.68.58.8]) by mtv-iport-1.cisco.com with ESMTP; 17 Dec 2013 16:49:03 +0000 Received: from sjc-savbu-bld03.cisco.com (sjc-savbu-bld03.cisco.com [171.71.188.58]) by mtv-core-3.cisco.com (8.14.5/8.14.5) with ESMTP id rBHGn36K016724; Tue, 17 Dec 2013 16:49:03 GMT Received: by sjc-savbu-bld03.cisco.com (Postfix, from userid 246720) id 9FE943F7E4; Tue, 17 Dec 2013 08:49:03 -0800 (PST) From: Upinder Malhi To: linux-rdma@vger.kernel.org Cc: Upinder Malhi Subject: [PATCH for-next 4/9] IB/usnic: Fix error handling with IS_ERR_OR_NULL Date: Tue, 17 Dec 2013 08:48:32 -0800 Message-Id: <1387298917-7365-5-git-send-email-umalhi@cisco.com> X-Mailer: git-send-email 1.8.0-rc0 In-Reply-To: <1387298917-7365-1-git-send-email-umalhi@cisco.com> References: <1387298917-7365-1-git-send-email-umalhi@cisco.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-15.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Errors with IS_ERR_OR_NULL are not handleded correctly in few places in usNIC. This patch remedies that. Signed-off-by: Upinder Malhi --- drivers/infiniband/hw/usnic/usnic_ib_main.c | 10 ++++++---- drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/usnic/usnic_ib_main.c b/drivers/infiniband/hw/usnic/usnic_ib_main.c index 4d8cadc..7200861 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_main.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_main.c @@ -398,13 +398,14 @@ static struct usnic_ib_dev *usnic_ib_discover_pf(struct usnic_vnic *vnic) us_ibdev = usnic_ib_device_add(parent_pci); if (IS_ERR_OR_NULL(us_ibdev)) { - us_ibdev = ERR_PTR(-EINVAL); + us_ibdev = (us_ibdev) ? us_ibdev : ERR_PTR(-EFAULT); goto out; } err = usnic_ib_sysfs_register_usdev(us_ibdev); if (err) { usnic_ib_device_remove(us_ibdev); + us_ibdev = ERR_PTR(err); goto out; } @@ -459,9 +460,10 @@ int usnic_ib_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) } pf = usnic_ib_discover_pf(vf->vnic); - if (!pf) { - usnic_err("Failed to discover pf of vnic %s with err%d\n", - pci_name(pdev), err); + if (IS_ERR_OR_NULL(pf)) { + usnic_err("Failed to discover pf of vnic %s with err%ld\n", + pci_name(pdev), PTR_ERR(pf)); + err = (pf ? PTR_ERR(pf) : -EFAULT); goto out_clean_vnic; } diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c index d305e4e..e19ca90 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c @@ -574,7 +574,7 @@ struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length, mr->umem = usnic_uiom_reg_get(to_upd(pd)->umem_pd, start, length, access_flags, 0); if (IS_ERR_OR_NULL(mr->umem)) { - err = PTR_ERR(mr->umem); + err = (mr->umem) ? PTR_ERR(mr->umem) : -EFAULT; goto err_free; }