Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp721698ybl; Tue, 13 Aug 2019 01:22:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwe6k5YcV3ieAbqh8l8R2ovif34ibNpmfySHlzUwhSH0ldsjoYRlB/Xd7Vq9KWiONneCesV X-Received: by 2002:aa7:8e10:: with SMTP id c16mr38771337pfr.124.1565684558351; Tue, 13 Aug 2019 01:22:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565684558; cv=none; d=google.com; s=arc-20160816; b=oPW7FiWmjni+IPVAH6O97FhcFis+Nl2dqiFLuHxo2dSMC8ooFuLpuB/aMp2D+bZKAB mHztXWJr63Y3h9n8mqxlBHtJmdrfADg/cYDq0rnJQu043HBMLVYZiwNSGdFvZB8SM0qq USB21EF8TK9TJq0P9jmcnpwAQMzrp7QqccjmT9V89S/pcD1hje7LfHBYE810UEYIaX2q DXcOeJQ5mbM2Y7mcdc2EFzcfJXT82OJJdF7Ba7RO+U3+mPoeFMrC05/G6qum03diwm9y LDsKLsc1w279ZWSK20ASA4WrzrRVz00TapUQOqsmDuJLmwAiHHnk1DIQYJr/CTLco9T0 jfKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=N1mXJQ2lz0aRkdfGXRBshymJFFzUA0I3F3Yqy4okoXg=; b=vKL8J12v6f45VS/88FzPSjgtS+6qAvRrH0YydlzEgd2vWH4biOMAe7RX81hr8ga00Q GSqX0oie7KHR5MimJitmX7awhE0Tgl54hyIutsQRYVsXFmo4PKMr8J/R/LqqF1N0SuqF Vr1eiFIv3iwBHjbefg6sPCJgFC8GKszcVvYtkVDgjQp0WzHM0ERpvn4Kg1LW8p4tvfYj Rf0nbaXbK8o11WTkaUepv/b3fjo1ilb8xygEANoG0UYJz172xoCzoaOOM1Soe35a9kq8 Z72C+2eqDj1JVNEjn5HDD14KHibd28mrTqbcyExOCKCyuypHU22Fy3iFsVPwIjXfrD38 0auQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 11si59554720pla.248.2019.08.13.01.22.21; Tue, 13 Aug 2019 01:22:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727777AbfHMIVr (ORCPT + 99 others); Tue, 13 Aug 2019 04:21:47 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:34522 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727029AbfHMIVq (ORCPT ); Tue, 13 Aug 2019 04:21:46 -0400 Received: by mail-yw1-f65.google.com with SMTP id n126so2089847ywf.1; Tue, 13 Aug 2019 01:21:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=N1mXJQ2lz0aRkdfGXRBshymJFFzUA0I3F3Yqy4okoXg=; b=sDEC9jOCbIKkPp0TzegpNpxfDvgn3a42c1vLMpmhnxWIHyNjbmMwgWHyyDTY82mWPN fO8721aEdAeZ5drLQuJA1NYVUxATnefwB+hfr504cxnUN4ygJUbhzZJfF7A0J/FV7wxM 887KrGIWneVFG33Ys7gtaLqRkFGS+fnHUPoko0kKPWM7nQ5s1TDJ3CkwXW9xCQhzI4wx BlkK9fd4ZxrcwIpyafUTC6NScwTrLnTBR6FyNGgy90NxXldMgNNBvQ0I6Qk5H/DXZAv/ 9OgpfNgV5E8zIp5Pm3XXM3bnj0NUCCjesBaCZk1TOeVxDLHk81OPidUOnGqzk7v6okTQ /aLQ== X-Gm-Message-State: APjAAAUnEKFfW2Gt3O/nnt07FSz5/orQw1F2KeCuWAGMk3YbtkFEestl 8nH2yx4R7zcjqGZ6TfiiX9Y= X-Received: by 2002:a81:a34c:: with SMTP id a73mr14295421ywh.379.1565684505739; Tue, 13 Aug 2019 01:21:45 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id z6sm25027153ywg.40.2019.08.13.01.21.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Aug 2019 01:21:44 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , netdev@vger.kernel.org (open list:MELLANOX MLX5 core VPI driver), linux-rdma@vger.kernel.org (open list:MELLANOX MLX5 core VPI driver), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] net/mlx5: Fix a memory leak bug Date: Tue, 13 Aug 2019 03:21:35 -0500 Message-Id: <1565684495-2454-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In mlx5_cmd_invoke(), 'ent' is allocated through kzalloc() in alloc_cmd(). After the work is queued, wait_func() is invoked to wait the completion of the work. If wait_func() returns -ETIMEDOUT, the following execution will be terminated. However, the allocated 'ent' is not deallocated on this program path, leading to a memory leak bug. To fix the above issue, free 'ent' before returning the error. Signed-off-by: Wenwen Wang --- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c index 8cdd7e6..90cdb9a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c @@ -1036,7 +1036,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, err = wait_func(dev, ent); if (err == -ETIMEDOUT) - goto out; + goto out_free; ds = ent->ts2 - ent->ts1; op = MLX5_GET(mbox_in, in->first.data, opcode); -- 2.7.4