From patchwork Mon Oct 19 16:57:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Insu Yun X-Patchwork-Id: 7438791 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 01AE29F36A for ; Mon, 19 Oct 2015 16:55:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2236D20529 for ; Mon, 19 Oct 2015 16:55:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 494B12051A for ; Mon, 19 Oct 2015 16:55:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751414AbbJSQzx (ORCPT ); Mon, 19 Oct 2015 12:55:53 -0400 Received: from mail-yk0-f176.google.com ([209.85.160.176]:36295 "EHLO mail-yk0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750905AbbJSQzw (ORCPT ); Mon, 19 Oct 2015 12:55:52 -0400 Received: by ykdz2 with SMTP id z2so63673427ykd.3 for ; Mon, 19 Oct 2015 09:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=mmBG6Mtj2jxhDeL6ym0oRN/hyOmH/uzlCyNrRVWWAF4=; b=CcakycWAMQEbO1Yqf9ie+RYvkpUeU7IhtJ5Xinn1gIlFbGbbNHtvOI6ozznesNuEhc nNIxehOpl/GB5Yv97YBL8cgJyZZxi3Vz862++z/antBa0qjZ4gUiprKieLTihVVph8xU cn8MRdMptnAFotooTD0USCp251qRO8o2ETlOVO5XF+t0DqsQ6KfHHoPbCSENi98cr7xa wzzMQUFz1UWI4y808EFw9RYQbom9PP61cl4hyD2iFZHcDeFqfgqemKfDcBFjDMOXVYGF 7wXuY1GcTyioZbadtc/DU0Av9lBw01SM252Nngxjx724yHX5eo8nD55cBwfMm567N1k5 tSFg== X-Received: by 10.129.77.132 with SMTP id a126mr593597ywb.184.1445273752357; Mon, 19 Oct 2015 09:55:52 -0700 (PDT) Received: from cutthroat.gtisc.gatech.edu (cutthroat.gtisc.gatech.edu. [128.61.240.77]) by smtp.gmail.com with ESMTPSA id j63sm7274490ywg.52.2015.10.19.09.55.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Oct 2015 09:55:51 -0700 (PDT) From: Insu Yun To: dledford@redhat.com, linux-rdma@vger.kernel.org Cc: taesoo@gatech.edu, yeongjin.jang@gatech.edu, insu@gatech.edu, changwoo@gatech.edu, Insu Yun Subject: [PATCH] usnic: correctly handle kzalloc return value Date: Mon, 19 Oct 2015 16:57:10 +0000 Message-Id: <1445273830-25909-1-git-send-email-wuninsu@gmail.com> X-Mailer: git-send-email 1.9.1 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 Since kzalloc returns memory address, not error code, it should be checked whether it is null or not. Signed-off-by: Insu Yun Reviewed-by: Dave Goodell --- drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c index db3588d..a678a66 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c @@ -221,8 +221,8 @@ create_roce_custom_flow(struct usnic_ib_qp_grp *qp_grp, /* Create Flow Handle */ qp_flow = kzalloc(sizeof(*qp_flow), GFP_ATOMIC); - if (IS_ERR_OR_NULL(qp_flow)) { - err = qp_flow ? PTR_ERR(qp_flow) : -ENOMEM; + if (!qp_flow) { + err = -ENOMEM; goto out_dealloc_flow; } qp_flow->flow = flow; @@ -296,8 +296,8 @@ create_udp_flow(struct usnic_ib_qp_grp *qp_grp, /* Create qp_flow */ qp_flow = kzalloc(sizeof(*qp_flow), GFP_ATOMIC); - if (IS_ERR_OR_NULL(qp_flow)) { - err = qp_flow ? PTR_ERR(qp_flow) : -ENOMEM; + if (!qp_flow) { + err = -ENOMEM; goto out_dealloc_flow; } qp_flow->flow = flow;