Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3371166pxu; Sun, 20 Dec 2020 00:15:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfUpjYoBBRLOT1gLGyVaaQvDPzE+oRJl9gaPoWeo+5HmQLSaeEoUmZb/ZaBOvEG9W61h22 X-Received: by 2002:aa7:da01:: with SMTP id r1mr11748431eds.45.1608452122454; Sun, 20 Dec 2020 00:15:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608452122; cv=none; d=google.com; s=arc-20160816; b=Ea9wpCNncCUcpKji0HnLkA1CO6FrZzUIl+bCULpz98jB0uTz20RIgMrQRW1y89+mg7 KC48re4PbxHDlGQLKeVrHmWIBUbey49VuGLS+vd1ad/BJGZs1auhJJ/UGhhRL9avmjDE ZMJMGtB9KpgqW713HR4186Z61fQcjOEQLVlnxtwp9t6m1WYNcZzFRqq6a3CpxgbkCcvT OkuTEd2bDfTEuwAtdC8JzTWDh5rELqVvBV6l9XDt2g89/dzL4/JMsj46WUlhSRfHqt6j BP1ii1aA7GoPNrcW9Mi65lXDpVeyt2nyvldFuhzFGAASVRHt0qexb1FsVTY9FAl4s218 /j/A== 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; bh=IEqfkRrRmuPhEFW7x4WfweHJgM/93uABTbNZ2iD1bF4=; b=j8Gs7w1Cec4Ooo0QklHR7ReWPVshGBd5ofM4dtTBuloKrLjtozICxgAygN7xaF8JM3 bCwvQ2sLs+sw3P/C1DXNfRQ0/icCyiqy68IezK/1ISnYLRnOujGWHmu2g5qtxBdlSdhk 06D6JGvSkPCaTrMGhmWb5wPxMEvj5Fpilrp4jZGgdOT28W0ykh62vaaO8TjC3VDNV+h4 NJsawYTXvRMBc+9DMs8lYA/cSlv03+WA3YRCs2atw3rD/seqOn1aEi1UBKfpa1FJ8iZu 4Uq7UNjJNyC0ciFTziIZsT9IUgcDFE0jpFHpzYJmO3Q2glZG5WtQWoyeV1nEUqfXyDMU tsWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v1si9777442edl.62.2020.12.20.00.14.58; Sun, 20 Dec 2020 00:15:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727282AbgLTIO3 (ORCPT + 99 others); Sun, 20 Dec 2020 03:14:29 -0500 Received: from spam.zju.edu.cn ([61.164.42.155]:44396 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727190AbgLTIO3 (ORCPT ); Sun, 20 Dec 2020 03:14:29 -0500 Received: from localhost.localdomain (unknown [10.192.85.18]) by mail-app3 (Coremail) with SMTP id cC_KCgA3_+ydB99fmttYAA--.15457S4; Sun, 20 Dec 2020 16:13:22 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: Doug Ledford , Jason Gunthorpe , "Gustavo A. R. Silva" , Ursula Braun , Leon Romanovsky , =?UTF-8?q?H=C3=A5kon=20Bugge?= , Divya Indi , Mauro Carvalho Chehab , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] IB/sa: Fix memleak in ib_nl_make_request Date: Sun, 20 Dec 2020 16:13:14 +0800 Message-Id: <20201220081317.18728-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cC_KCgA3_+ydB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oOJ5UUUUU X-CM-SenderInfo: qrrzjiaqtzq6lmxovvfxof0/1tbiAgUMBlZdtRf+rwAHsy Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When rdma_nl_multicast() fails, skb should be freed just like when ibnl_put_msg() fails. Signed-off-by: Dinghao Liu --- drivers/infiniband/core/sa_query.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index 89a831fa1885..8bd23b5cc913 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c @@ -873,8 +873,10 @@ static int ib_nl_make_request(struct ib_sa_query *query, gfp_t gfp_mask) spin_lock_irqsave(&ib_nl_request_lock, flags); ret = rdma_nl_multicast(&init_net, skb, RDMA_NL_GROUP_LS, gfp_flag); - if (ret) + if (ret) { + nlmsg_free(skb); goto out; + } /* Put the request on the list.*/ delay = msecs_to_jiffies(sa_local_svc_timeout_ms); -- 2.17.1