Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755367AbdIRL24 (ORCPT ); Mon, 18 Sep 2017 07:28:56 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:37668 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754662AbdIRL2z (ORCPT ); Mon, 18 Sep 2017 07:28:55 -0400 X-Google-Smtp-Source: ADKCNb6W53Zs4uHr71GSG30dTB50lVsEAm3ZoYvoyXCXn1nMEYNkm6cSOrZWwnc9NNYQGrn1E9Wq0Q== From: Sudip Mukherjee X-Google-Original-From: Sudip Mukherjee To: Matan Barak , Leon Romanovsky , Doug Ledford , Sean Hefty , Hal Rosenstock Cc: linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Sudip Mukherjee Subject: [PATCH v2] IB/mlx5: fix debugfs cleanup Date: Mon, 18 Sep 2017 12:28:48 +0100 Message-Id: <1505734128-21708-1-git-send-email-sudip.mukherjee@codethink.co.uk> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1425 Lines: 45 From: Sudip Mukherjee If delay_drop_debugfs_init() fails in any of the operations to create debugfs, it is calling delay_drop_debugfs_cleanup() as part of its cleanup. But delay_drop_debugfs_cleanup() checks for 'dbg' and since we have not yet pointed 'dbg' to the debugfs we need to cleanup, the cleanup fails and we are left with stray debugfs elements and also a memory leak. Fixes: 4a5fd5d2965c ("IB/mlx5: Add necessary delay drop assignment") Signed-off-by: Sudip Mukherjee --- drivers/infiniband/hw/mlx5/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index ab3c562..05fb4bd 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -3837,11 +3837,13 @@ static int delay_drop_debugfs_init(struct mlx5_ib_dev *dev) if (!dbg) return -ENOMEM; + dev->delay_drop.dbg = dbg; + dbg->dir_debugfs = debugfs_create_dir("delay_drop", dev->mdev->priv.dbg_root); if (!dbg->dir_debugfs) - return -ENOMEM; + goto out_debugfs; dbg->events_cnt_debugfs = debugfs_create_atomic_t("num_timeout_events", 0400, @@ -3865,8 +3867,6 @@ static int delay_drop_debugfs_init(struct mlx5_ib_dev *dev) if (!dbg->timeout_debugfs) goto out_debugfs; - dev->delay_drop.dbg = dbg; - return 0; out_debugfs: -- 2.7.4