From patchwork Tue Feb 2 21:13:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 8195651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0110D9F3CD for ; Tue, 2 Feb 2016 21:17:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21DC4202BE for ; Tue, 2 Feb 2016 21:17:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CCF82027D for ; Tue, 2 Feb 2016 21:17:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQiIU-00035F-BK; Tue, 02 Feb 2016 21:15:38 +0000 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQiHW-0001Bx-4u for linux-arm-kernel@lists.infradead.org; Tue, 02 Feb 2016 21:14:40 +0000 Received: by mail-pf0-x22d.google.com with SMTP id 65so566203pfd.2 for ; Tue, 02 Feb 2016 13:14:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YgMHPooNTEEgV/AGMSCehNecAIJr93AK9JuYNjD4EMM=; b=CZr5vmmmsj81lhs6UWSj/FZz8Syk2nxSBGDN0tEG6jKzMp34RzOvEQHIJeVmc3gR5M WzKIEv7R1q50ZI8FL/Pyc68++JrPMbieGQD4WRj5VtgyAF+vopIFv+oquF0TVwj6SXrh iH+BlZEk4RNbDiFSdjYdb6TP1sh9ZB7ULQqZs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YgMHPooNTEEgV/AGMSCehNecAIJr93AK9JuYNjD4EMM=; b=FKt5LpmXUPuh68SxmbABdcNp69VqfqBL2ToM1xgRc1WlQi9u4v6fjMRtRZXq3K7QzM zrA+zvEOLMSaCGqm9fAYU3CZzNz+rLdluzXcbkLLfU8L40WE6BWpJyehVVzI0Wv1S6Oo 77AIIhpM7qFQla6/8ynO1DmwcEw99VvqGf6lLjgDKfgCvrMYgQyTwGx4EcfIw3NxYzMB 7852yMEujqyLar2Hxcs/6xt5njbAxNsE8GmT/wAE4ffnFiwXaEd5CPSp35L/EEMkbTkE Nvh51kl7iYEcY8fvcHS6c4kZM4gvbAAZkz+/AaQsy/EKHdy6kArfwosTLZ5pFFmWIPFP NKug== X-Gm-Message-State: AG10YOQHaQp7lHkPcG4PbZdASlXdU89ovdIcOoixrfK2fx49rN65J67sG/IcfIW2jjUAnd60 X-Received: by 10.98.10.65 with SMTP id s62mr18246635pfi.119.1454447657451; Tue, 02 Feb 2016 13:14:17 -0800 (PST) Received: from t430.cg.shawcable.net ([184.64.168.246]) by smtp.gmail.com with ESMTPSA id 79sm4769141pfr.22.2016.02.02.13.14.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Feb 2016 13:14:16 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 3/7] coresight: coresight_unregister() function cleanup Date: Tue, 2 Feb 2016 14:13:57 -0700 Message-Id: <1454447641-29153-4-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1454447641-29153-1-git-send-email-mathieu.poirier@linaro.org> References: <1454447641-29153-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160202_131438_425140_CFBCF325 X-CRM114-Status: GOOD ( 13.38 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In its current form the code never frees csdev->refcnt allocated in coresight_register(). There is also a problem with csdev->conns that is freed before device_unregister() rather than in the device release function. This patch addresses both issues by moving kfree(csdev->conns) to coresight_device_release() and freeing csdev->refcnt, also in the same function. Reported-by: Rabin Vincent Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 41b42018b660..8872db4410eb 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -481,6 +481,8 @@ static void coresight_device_release(struct device *dev) { struct coresight_device *csdev = to_coresight_device(dev); + kfree(csdev->conns); + kfree(csdev->refcnt); kfree(csdev); } @@ -713,7 +715,6 @@ EXPORT_SYMBOL_GPL(coresight_register); void coresight_unregister(struct coresight_device *csdev) { - kfree(csdev->conns); device_unregister(&csdev->dev); } EXPORT_SYMBOL_GPL(coresight_unregister);