From patchwork Sat Dec 3 03:37:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 29216 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1203583wrr; Fri, 2 Dec 2022 20:24:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf459It2geNhpD1ytU90KDURY0dUg6jgAJbJhJwm81SbyL+wS0RzmbBZ1OyCEdbcI4g9pgzh X-Received: by 2002:a17:903:181:b0:189:8f11:f2f with SMTP id z1-20020a170903018100b001898f110f2fmr28441415plg.133.1670041477261; Fri, 02 Dec 2022 20:24:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670041477; cv=none; d=google.com; s=arc-20160816; b=pS1mypz18Vb8IjgAGQx1uOsNIVDAKc393qfGcdT+XDCr0PC1LY6yWZhcfFPOmGS021 RYN8ZgXS8kv8uN1RmnTfmeSDNz9G49riRnHnbm+CG0gjEvtsBNaR5rRPHbE5l54BdGWt YYP1OpzSjP0AEOqpBDzfj8Xa/UtOtJb5Ac05aZ25C7cyRdOZKxm6eHs+fRwaEauRaWP6 Q+5Q4BXluGi4kW6XuLbKq2hDnPx+m6wVn+NPszvkybw6j7EiGZAsJRcIGo73SqQK/aaG ETpnH47DrQW3CwLZBLVHnKEfHGobslsRQp8Dh7U0gi7eBeVWaEMhSe1HFNOWZX3Qz2Mu g8uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=j8OgNmZ1YDFkOWEBnJUTe6fOCKvo019IUHX2X/l0IKM=; b=fhceo1ge+9am5uefRxzzVMV5Ls4znd69gLhtvlPfgfG2Qu0sXWo2iagA7b7y1ZdtTQ FLdu2ahFIxVEnQ+iTbsN8VCF7XLZ532EuYxBvLsTMcGwF4Z8/Wixs2ZgBjfVJwvQAFJU DMSg3ZmWxQYnPjlVeuuw6C+6n3J7xdOJBXntTE8aIG3wj2rKTgW2+yu92ivjbjXb80Zc rOT/KWCaAzOBCXNDMwDrREN8jOafQppFv+aBpZaCDg/+Yjsxj2gphKx9tZW8ycvnjZr5 wQYBa68UM5MSHjPTfOMBkMYQy42+w8rGTwP3oenC4/UEdN647/5KIpfQG5+3QnI9Dnxu 970g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bj2-20020a170902850200b0018929921900si7951147plb.80.2022.12.02.20.24.23; Fri, 02 Dec 2022 20:24:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbiLCDhd (ORCPT + 99 others); Fri, 2 Dec 2022 22:37:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbiLCDhb (ORCPT ); Fri, 2 Dec 2022 22:37:31 -0500 Received: from esa10.hc1455-7.c3s2.iphmx.com (esa10.hc1455-7.c3s2.iphmx.com [139.138.36.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46FC8A0557; Fri, 2 Dec 2022 19:37:27 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="86269280" X-IronPort-AV: E=Sophos;i="5.96,214,1665414000"; d="scan'208";a="86269280" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa10.hc1455-7.c3s2.iphmx.com with ESMTP; 03 Dec 2022 12:37:24 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id CED8BD3EA3; Sat, 3 Dec 2022 12:37:23 +0900 (JST) Received: from kws-ab2.gw.nic.fujitsu.com (kws-ab2.gw.nic.fujitsu.com [192.51.206.12]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 1B3F0F0A2D; Sat, 3 Dec 2022 12:37:23 +0900 (JST) Received: from FNSTPC.g08.fujitsu.local (unknown [10.167.226.45]) by kws-ab2.gw.nic.fujitsu.com (Postfix) with ESMTP id 2C75D23406A1; Sat, 3 Dec 2022 12:37:22 +0900 (JST) From: Li Zhijian To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Li Zhijian Subject: [PATCH] RDMA/mlx5: no need to kfree NULL pointer Date: Sat, 3 Dec 2022 11:37:14 +0800 Message-Id: <20221203033714.25870-1-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1408-9.0.0.1002-27300.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1408-9.0.1002-27300.005 X-TMASE-Result: 10--5.794900-10.000000 X-TMASE-MatchedRID: rWcK0WiM0yyjC979w1k7DErOO5m0+0gEmSLeIgEDej/AuQ0xDMaXkH4q tYI9sRE/ZNUDHbPZ5K3LtJAGcfCTs8QmX0k7dptpngIgpj8eDcAZ1CdBJOsoY9mzcdRxL+xwKra uXd3MZDUaA0E8UdrP6nF6eQOQrAVPaaC7MUsggjz+CsA1rmXCp5RZ3pKiHPN/ X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751165412402354531?= X-GMAIL-MSGID: =?utf-8?q?1751165412402354531?= Goto label 'free' where it will kfree the 'in' is not needed though it's safe to kfree NULL. Return err code directly to simplify the code. 1973 free: 1974 kfree(in); 1975 return err; Signed-off-by: Li Zhijian --- I stumbled across this little defect. --- drivers/infiniband/hw/mlx5/mr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index 410cc5fd2523..053fe946e45a 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -1929,10 +1929,8 @@ int mlx5_ib_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata) ndescs = req.num_klms ? roundup(req.num_klms, 4) : roundup(1, 4); in = kzalloc(inlen, GFP_KERNEL); - if (!in) { - err = -ENOMEM; - goto free; - } + if (!in) + return -ENOMEM; mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);