Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp49874imm; Tue, 5 Jun 2018 14:51:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJf2DHmZHhkZ51pE2Qqtat7Z2V8LlZaz06PpfdQbsa/J+sYhWBdRQdXKeWxmSp4rupeu7/7 X-Received: by 2002:a62:d0c5:: with SMTP id p188-v6mr333381pfg.101.1528235461922; Tue, 05 Jun 2018 14:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528235461; cv=none; d=google.com; s=arc-20160816; b=NtQwBt/iEiyty06agxMQpXDA5eUWZDVGC3pepExISgNw1mdTY6qNJrPcjfUV2ckeAM X/yKT0aUZCL0BWzvAuep+2TdSaBpfADlAN0F/UWiqCKmTR24nG4iFwexr27W8NZcH7Od KVRO4As11gu3WehrC3RoykRqKUfsiRkPX412VgxSGjqJJHrePha3qIuWDQ0Yv8WD9uvG 6oqkXhVo7dH0/NKN4elIgFRheP7uCC0tQP0o/J2LtA8h1afHknntmkc8Pb/EKEKG+Tki paiYth16c+tpAwvCXwssHH1h0AXU+jYYe4SiUKVZ9eEGkgrm7P4griibULROxj0oOLTL 9u7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=+M1uiNjiN9Tw02Dt8JSAZf7newZT0HM9o+iBtjt5o7c=; b=h8Nfw4548xFiWgZZ1E/xlT9uwpCdHa1kVwt/mJSS9ZmhW9bbEh7zoRYyeZVqVlX3Mc v5O6aNpunFHPya9VIU4DJP78D9eXkC0dA/6X7WCLRmMF8MMX08FWivg/F9F3gAHh13kZ P7GjdBr1M+qRS3AhQLzvXUoeWm8acQnBNcP+kLHBGqY/ddgMaWGxux2bKQsHZyKq3Ijj f29GGBHjtNKyznT/nUuzhEqU66G4xJn6Z6QUp5Pnh/U6DX59rkibl/cjm33rMK3lrzO4 zjvX0wBW0L21Tfzk342Gw+LBLEpUtTmBh8iiCu1Fs2TKLxixPOa9iR9TCw0CmtezOPfe l9AA== 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 r12-v6si522268pfe.9.2018.06.05.14.50.47; Tue, 05 Jun 2018 14:51:01 -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 S1752683AbeFEVov (ORCPT + 99 others); Tue, 5 Jun 2018 17:44:51 -0400 Received: from foss.arm.com ([217.140.101.70]:34420 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751780AbeFEVor (ORCPT ); Tue, 5 Jun 2018 17:44:47 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 484381529; Tue, 5 Jun 2018 14:44:47 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 950013F59D; Tue, 5 Jun 2018 14:44:44 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, robh@kernel.org, frowand.list@gmail.com, mark.rutland@arm.com, sudeep.holla@arm.com, arm@kernel.org, linux-kernel@vger.kernel.org, matt.sealey@arm.com, john.horley@arm.com, charles.garcia-tobin@arm.com, coresight@lists.linaro.org, devicetree@vger.kernel.org, mike.leach@linaro.org, Suzuki K Poulose , Arvind Yadav Subject: [PATCH 01/20] coresight: Fix memory leak in coresight_register Date: Tue, 5 Jun 2018 22:43:12 +0100 Message-Id: <1528235011-30691-2-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> References: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 6403587a930c ("coresight: use put_device() instead of kfree()") introduced a memory leak where, if we fail to register the device for coresight_device, we don't free the "coresight_device" object, which was allocated via kzalloc(). Fix this by jumping to the appropriate error path. Fixes: commit 6403587a930c ("coresight: use put_device() instead of kfree()") Cc: Mathieu Poirier Cc: Arvind Yadav Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 4969b32..2893cfe 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1020,7 +1020,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) ret = device_register(&csdev->dev); if (ret) { put_device(&csdev->dev); - goto err_kzalloc_csdev; + goto err_kzalloc_refcnts; } mutex_lock(&coresight_mutex); -- 2.7.4