Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp778929pxp; Fri, 11 Mar 2022 14:55:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnKa5aFDWrvKMAp+6krHx8xEIv6JgL/0Uinv+OyQ1Jezf5pIc6K2wIC1PRXmj4fQWgEgaK X-Received: by 2002:a63:ef4f:0:b0:375:6898:f6b8 with SMTP id c15-20020a63ef4f000000b003756898f6b8mr10320996pgk.59.1647039354676; Fri, 11 Mar 2022 14:55:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647039354; cv=none; d=google.com; s=arc-20160816; b=IDZeCWRXuGNqvKHAq7T2fgp0jSJF7t5u9ueaDQ7xPM2lWtzRKUGNahcWfBJXdSZ35v 3UDB7bYbaQuc/9H5rsJuXDC/Rv2KFGYalrUUJ1504u2zRmOaBDJi709mZGinU+6JKQ7U wTkQ3IFdQ6Bzp32LEUvM/ZUrfS3eEugeIOxmLTqVu/TtahLF7LEwpOrmeYIQ148b+j4H kzXrzu8G2jYnKLSd9QaDXxw9lSK86h5XFh7X+DRKPsn4JBNI06aTCVq5jmfkZJeNEmlM utg5cg0bm9k61j9ByK8y33rxbhZttRRi1W5uhyhcKfjvWB4ugYitILgryUWWJrU8QtKy voWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=yUZNbj+mFhT5GgO79ZxbHQUCuPOmg45HEXuYwzHNgEQ=; b=WOt0M+FgY7u1BpjCJcYnIzQTnWjo2jaZ1rkG2ocms8ic9ZcgXRkLzID995ItiCToyI ESsf36Lo32d/5maHHQxjibUNsrY4tBfttiPVhnFMTZ/bbZobS8dYZrz8GW8aAfM/si9W W+p2D+3Gi4MC0Ev5ZePpRMXwMMak5sgACcDN+7aRrd2M73ik1DjPZarX1decOmlUY9JB EFhsZSrGneIelC9J+Dd5gu+Kxa5RnoUXwQ3uwB8S+u+bk/IAcY5UeOd/U4q7gjANL6xy I5/t89IYhjQR/n1fkPYT3NIek85z3L4uL90zASgdyvC1/jSt0RuwY8Xm6xmIOrzamge4 PKhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@pku.edu.cn header.s=dkim header.b="bl/cLrUP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=pku.edu.cn Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y5-20020a17090322c500b00151f12cda43si9415294plg.425.2022.03.11.14.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:55:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@pku.edu.cn header.s=dkim header.b="bl/cLrUP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=pku.edu.cn Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 63F312923DF; Fri, 11 Mar 2022 13:53:19 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350507AbiCKRHd (ORCPT + 99 others); Fri, 11 Mar 2022 12:07:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231310AbiCKRHc (ORCPT ); Fri, 11 Mar 2022 12:07:32 -0500 Received: from zg8tmty1ljiyny4xntqumjca.icoremail.net (zg8tmty1ljiyny4xntqumjca.icoremail.net [165.227.154.27]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 79A0EA9954; Fri, 11 Mar 2022 09:06:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pku.edu.cn; s=dkim; h=Received:From:To:Cc:Subject:Date: Message-Id; bh=yUZNbj+mFhT5GgO79ZxbHQUCuPOmg45HEXuYwzHNgEQ=; b=b l/cLrUP11fdJ1KL0f/zCeNs45kBab316RJZzweydFKgIjSVXNqho32NsLjH0ve9A /RZchKdCA2om0oiyAbT2Y+yOGqw4uLEOQE3yjfEBQdUzaMXMpwfZSzgu0qUySYF/ 5zouxF5FDVmluiyyPDhzDEvCE6wfjQ+hpcgfuY9eB8= Received: from localhost (unknown [10.129.21.144]) by front01 (Coremail) with SMTP id 5oFpogA3P1N7gStiYnwIAA--.11214S2; Sat, 12 Mar 2022 01:06:03 +0800 (CST) From: Yongzhi Liu To: leon@kernel.org, jgg@ziepe.ca, yishaih@mellanox.com Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, fuyq@stu.pku.edu.cn, Yongzhi Liu Subject: [PATCH] RDMA/mlx5: Fix memory leak Date: Fri, 11 Mar 2022 09:06:01 -0800 Message-Id: <1647018361-18266-1-git-send-email-lyz_cs@pku.edu.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: 5oFpogA3P1N7gStiYnwIAA--.11214S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Wr48Ww4kWw18ur48GFWUCFg_yoWDGrb_Gr 1qv3s7Xa45AFnakryDCrs7WryI9r4UWw1xXr1vg3Wak393CayUCa9aqF9Yvw17JrWYgFyj yrnFkr1xAw4FgjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbx8Fc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wAFIxvE14AK wVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20x vE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwA2z4x0Y4vEx4A2 jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1le2I262IYc4 CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_ Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x 0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK6svPMxAIw28IcxkI7VAKI48J MxAIw28IcVCjz48v1sIEY20_Kr1UJr1l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4 xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1D MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I 0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWU JVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JUdHU DUUUUU= X-CM-SenderInfo: irzqijirqukmo6sn3hxhgxhubq/1tbiAwESBlPy7ubR6QAjsk X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 [why] xa_insert is failed, so caller of subscribe_event_xa_alloc cannot call other function to free obj_event. Therefore, Resource release is needed on the error handling path to prevent memory leak. [how] Fix this by adding kfree on the error handling path. Fixes: 7597385 ("IB/mlx5: Enable subscription for device events over DEVX") Signed-off-by: Yongzhi Liu --- drivers/infiniband/hw/mlx5/devx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c index 08b7f6b..15c0884 100644 --- a/drivers/infiniband/hw/mlx5/devx.c +++ b/drivers/infiniband/hw/mlx5/devx.c @@ -1886,8 +1886,10 @@ subscribe_event_xa_alloc(struct mlx5_devx_event_table *devx_event_table, key_level2, obj_event, GFP_KERNEL); - if (err) + if (err) { + kfree(obj_event); return err; + } INIT_LIST_HEAD(&obj_event->obj_sub_list); } -- 2.7.4