Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756287AbcDLIfz (ORCPT ); Tue, 12 Apr 2016 04:35:55 -0400 Received: from mga09.intel.com ([134.134.136.24]:63209 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756262AbcDLIfy (ORCPT ); Tue, 12 Apr 2016 04:35:54 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,473,1455004800"; d="scan'208";a="83555232" From: changbin.du@intel.com To: balbi@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Du, Changbin" Subject: [PATCH v3] usb: dwc3: fix memory leak of dwc->regset Date: Tue, 12 Apr 2016 16:24:34 +0800 Message-Id: <1460449474-26540-1-git-send-email-changbin.du@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <87k2k3kzbe.fsf@intel.com> References: <87k2k3kzbe.fsf@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 947 Lines: 39 From: "Du, Changbin" dwc->regset is allocated on dwc3_debugfs_init, and should be released on init failure or dwc3_debugfs_exit. Btw, The line "dwc->root = NULL" is unnecessary, so remove it. Signed-off-by: Du, Changbin --- v3: remove unnecessary if(!NULL) for free v2: Title changed; free dwc->regset on failure path. --- drivers/usb/dwc3/debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index 9ac37fe..07d99eb 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c @@ -678,7 +678,7 @@ int dwc3_debugfs_init(struct dwc3 *dwc) err1: debugfs_remove_recursive(root); - + kfree(dwc->regset); err0: return ret; } @@ -686,5 +686,5 @@ err0: void dwc3_debugfs_exit(struct dwc3 *dwc) { debugfs_remove_recursive(dwc->root); - dwc->root = NULL; + kfree(dwc->regset); } -- 2.5.0