From patchwork Mon Sep 21 13:33:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 7231071 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 27FEDBEEC1 for ; Mon, 21 Sep 2015 13:53:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56C122076D for ; Mon, 21 Sep 2015 13:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 66A6C20764 for ; Mon, 21 Sep 2015 13:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756262AbbIUNxB (ORCPT ); Mon, 21 Sep 2015 09:53:01 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:40457 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756868AbbIUNgP (ORCPT ); Mon, 21 Sep 2015 09:36:15 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NV100J3P4GCQH40@mailout4.w1.samsung.com>; Mon, 21 Sep 2015 14:36:12 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-b7-560007cc4b81 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id FF.57.04846.CC700065; Mon, 21 Sep 2015 14:36:12 +0100 (BST) Received: from AMDC1061.digital.local ([106.116.147.88]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NV100LNT4DTKI10@eusync3.samsung.com>; Mon, 21 Sep 2015 14:36:12 +0100 (BST) From: Andrzej Hajda To: linux-kernel@vger.kernel.org Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , Doug Ledford , Sean Hefty , Hal Rosenstock , Greg Kroah-Hartman , linux-rdma@vger.kernel.org, devel@driverdev.osuosl.org Subject: [PATCH 04/38] IB/ehca: fix handling idr_alloc result Date: Mon, 21 Sep 2015 15:33:36 +0200 Message-id: <1442842450-29769-5-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1442842450-29769-1-git-send-email-a.hajda@samsung.com> References: <1442842450-29769-1-git-send-email-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHLMWRmVeSWpSXmKPExsVy+t/xq7pn2BnCDA6fYbK4te4cq8XGGetZ Lfac+cVu8fL8B1aL5sXr2Sw2bp7IaHF51xw2i2eHelks1h65y27RvH4DiwOXx719h1k8ds66 y+6xeM9LJo/9c9ewe7zfd5XNo2/LKkaPz5vkAtijuGxSUnMyy1KL9O0SuDI+zj3GVHCKv+LQ vd3sDYwveLoYOTkkBEwklj3awA5hi0lcuLeerYuRi0NIYCmjxIXZM5khnCYmic7925lAqtgE NCX+br7JBmKLCChIbO59xgpSxCzwkUmi9+dSZpCEsICtxIupn1hBbBYBVYnPP16AreAVcJb4 /qmJBWKdnMTJY5PBajgFXCQOHPwCFhcCqjmw5AjTBEbeBYwMqxhFU0uTC4qT0nMN9YoTc4tL 89L1kvNzNzFCQvHLDsbFx6wOMQpwMCrx8DoI/A8VYk0sK67MPcQowcGsJMKrMwsoxJuSWFmV WpQfX1Sak1p8iFGag0VJnHfurvchQgLpiSWp2ampBalFMFkmDk6pBsbgkvtaNc/itQ8cvNKz z1oqmN94ql63qXfqIdkXvnuC7s1f2Re4XjEm3OeLWqBimEbMeqFqTaYi5wfzj27utp715tBJ u5Qk3RthP5w/HV7X9+z5spV55vNrvzHYTWqZXqp15PjKxU8dA2vTRR3lXzcGrLwadHj/+xXO 5kl7hV38TL7YKOvcFVViKc5INNRiLipOBACHmLq+QQIAAA== Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY 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 The function can return negative value. The problem has been detected using proposed semantic patch scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2038576 Signed-off-by: Andrzej Hajda Acked-by: Doug Ledford --- drivers/staging/rdma/ehca/ehca_cq.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rdma/ehca/ehca_cq.c b/drivers/staging/rdma/ehca/ehca_cq.c index 9b68b17..ea1b5c1 100644 --- a/drivers/staging/rdma/ehca/ehca_cq.c +++ b/drivers/staging/rdma/ehca/ehca_cq.c @@ -130,7 +130,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, void *vpage; u32 counter; u64 rpage, cqx_fec, h_ret; - int ipz_rc, i; + int rc, i; unsigned long flags; if (attr->flags) @@ -170,16 +170,17 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, idr_preload(GFP_KERNEL); write_lock_irqsave(&ehca_cq_idr_lock, flags); - my_cq->token = idr_alloc(&ehca_cq_idr, my_cq, 0, 0x2000000, GFP_NOWAIT); + rc = idr_alloc(&ehca_cq_idr, my_cq, 0, 0x2000000, GFP_NOWAIT); write_unlock_irqrestore(&ehca_cq_idr_lock, flags); idr_preload_end(); - if (my_cq->token < 0) { + if (rc < 0) { cq = ERR_PTR(-ENOMEM); ehca_err(device, "Can't allocate new idr entry. device=%p", device); goto create_cq_exit1; } + my_cq->token = rc; /* * CQs maximum depth is 4GB-64, but we need additional 20 as buffer @@ -195,11 +196,11 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, goto create_cq_exit2; } - ipz_rc = ipz_queue_ctor(NULL, &my_cq->ipz_queue, param.act_pages, + rc = ipz_queue_ctor(NULL, &my_cq->ipz_queue, param.act_pages, EHCA_PAGESIZE, sizeof(struct ehca_cqe), 0, 0); - if (!ipz_rc) { + if (!rc) { ehca_err(device, "ipz_queue_ctor() failed ipz_rc=%i device=%p", - ipz_rc, device); + rc, device); cq = ERR_PTR(-EINVAL); goto create_cq_exit3; }