From patchwork Thu Jan 9 22:47:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Upinder Malhi (umalhi)" X-Patchwork-Id: 3463441 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 0E7619F2E9 for ; Thu, 9 Jan 2014 22:48:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3814E20103 for ; Thu, 9 Jan 2014 22:48:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 28953200F3 for ; Thu, 9 Jan 2014 22:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756446AbaAIWsF (ORCPT ); Thu, 9 Jan 2014 17:48:05 -0500 Received: from mtv-iport-3.cisco.com ([173.36.130.14]:51746 "EHLO mtv-iport-3.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756126AbaAIWr6 (ORCPT ); Thu, 9 Jan 2014 17:47:58 -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=1389307678; x=1390517278; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=mQ1SJc/YicCQ4X4LFm5GUTxo2Eq3YpTLpNDDxZek7vE=; b=AhUde6MmH4SoO9R42lUeFjQii/b/oD8x3eVASnhKUM//tbLNeoMfj4lp U/R0gxXhy50Ehdvjmdzxkk9zNCbTNUpJZGv4Y19JxrtT6xJBKDqCjDi0J J/GgPp2PQGkeSaAYcKzmZ8j2QEEhQb9OmFhVuj0D20QOetlNBxKL/4CYL k=; X-IronPort-AV: E=Sophos;i="4.95,634,1384300800"; d="scan'208";a="99936702" Received: from mtv-core-2.cisco.com ([171.68.58.7]) by mtv-iport-3.cisco.com with ESMTP; 09 Jan 2014 22:47:57 +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 s09MlvCD022152; Thu, 9 Jan 2014 22:47:57 GMT Received: by sjc-savbu-bld03.cisco.com (Postfix, from userid 246720) id 018D53F588; Thu, 9 Jan 2014 14:47:56 -0800 (PST) From: Upinder Malhi To: linux-rdma@vger.kernel.org, roland@kernel.org Cc: Upinder Malhi Subject: [PATCH v1 for-next 04/15] IB/usnic: Fix error handling with IS_ERR_OR_NULL Date: Thu, 9 Jan 2014 14:47:32 -0800 Message-Id: <1389307663-11296-5-git-send-email-umalhi@cisco.com> X-Mailer: git-send-email 1.8.0-rc0 In-Reply-To: <1389307663-11296-1-git-send-email-umalhi@cisco.com> References: <1389307663-11296-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=-14.5 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; }