From patchwork Fri Dec 20 20:26:35 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: 3391761 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 22ABD9F344 for ; Fri, 20 Dec 2013 20:27:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5366320704 for ; Fri, 20 Dec 2013 20:27:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69E5E20703 for ; Fri, 20 Dec 2013 20:27:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753063Ab3LTU1T (ORCPT ); Fri, 20 Dec 2013 15:27:19 -0500 Received: from mtv-iport-3.cisco.com ([173.36.130.14]:38142 "EHLO mtv-iport-3.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753042Ab3LTU1L (ORCPT ); Fri, 20 Dec 2013 15:27:11 -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=1387571231; x=1388780831; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=mQ1SJc/YicCQ4X4LFm5GUTxo2Eq3YpTLpNDDxZek7vE=; b=AmF7t2h8ZXK9gfDGRPiGEFRCJa1UU/qTgx+/PYVkU7z70aJaAah6GFpM qAx2ihld/hUATyiZu1StrqTlIE8uTR/meHBEzneKr+ppgMHg00Xm/7GxH VsoAywm4fwOO6ZhChNr/zywLkPr8yitaqy6H6jJMJH9MH8a6oxzo+3Txw U=; X-IronPort-AV: E=Sophos;i="4.95,523,1384300800"; d="scan'208";a="98539120" Received: from mtv-core-2.cisco.com ([171.68.58.7]) by mtv-iport-3.cisco.com with ESMTP; 20 Dec 2013 20:27:10 +0000 Received: from sjc-savbu-bld03.cisco.com (sjc-savbu-bld03.cisco.com [171.71.188.58]) by mtv-core-2.cisco.com (8.14.5/8.14.5) with ESMTP id rBKKR9d4028542; Fri, 20 Dec 2013 20:27:09 GMT Received: by sjc-savbu-bld03.cisco.com (Postfix, from userid 246720) id AF2243F7E4; Fri, 20 Dec 2013 12:27:09 -0800 (PST) From: Upinder Malhi To: linux-rdma@vger.kernel.org, roland@kernel.org Cc: Upinder Malhi Subject: [PATCH for-next 04/15] IB/usnic: Fix error handling with IS_ERR_OR_NULL Date: Fri, 20 Dec 2013 12:26:35 -0800 Message-Id: <1387571206-8043-5-git-send-email-umalhi@cisco.com> X-Mailer: git-send-email 1.8.0-rc0 In-Reply-To: <1387571206-8043-1-git-send-email-umalhi@cisco.com> References: <1387571206-8043-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 696e401..bf9c2d7 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; }