Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1625031ybv; Fri, 21 Feb 2020 00:31:13 -0800 (PST) X-Google-Smtp-Source: APXvYqz7MhWFU6uzh2Ya3sxKEvQUgcOZG/Xa1q/gzpmqM/G7bKa7rj4tD1zVNv9tB/yU+U63qMRH X-Received: by 2002:a05:6808:a8e:: with SMTP id q14mr978582oij.173.1582273873402; Fri, 21 Feb 2020 00:31:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273873; cv=none; d=google.com; s=arc-20160816; b=OurvgLFuY1cV5Dw2SbgwmLfyVUokc0HKQlDjfqu2lRGeq2uVeb6pKHAM5bXRAQIIkh zv5AipeCFXJ8oiGKq5BiP2MlE/FP+DDuvwQQcplkSErc9dJkVub/MuSU0taS65Alz/mG WK60xMQdA8kFDDrNntDb/o94dci2179wMunAa8RT3ggfQ5DcnqN7AFR35w8hHy3F+3r7 7YlseYW/DOI1LjMuSs5VLY7tl2lgGzJ3ut1FkZcnNsL28s4cdq4jqTYHEwKc6iwMJoZT vPYAIxIaMxOyzVXchiOC3mUa61bynkHKFJXeIDRq8f3nbWJBIHjux/dWJquUCaTpNc56 zmGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0wuc2NaMAbO0sxxWp+W/Uz8wtuVNVByAYrkEmWj6NDg=; b=Zk7d5bN4ZBP5oa0pnmXujOoYAIukuM78di2vCH8WcrieR3NSnGd9x2CtUlmvvYTF/t n8u7IU/hNOuQA+TtwUrKqYqVG6gxe8bVldGz6I0CBr8JJ+a7h2AQ2Y45Yd8OYUH/NnJc phxV+mWCRrDg2V2vZMDDlmjWJ2vfmMkBiY9lpgWiHWOYAPxVH0mNf1a0cVtESxXAHfYi hPL+GqW252U132x9AReYrW6Y4t0AGCFNm6ESjHtZpuJ28kN68kqgtmUS3l1pSbX0e647 8YsdL6M7z9iGlMEzfFwYHnRBZvq17GXh7CZ2PNRu/1RxZAIGb1uujckI5PEnIFZ51dbS qQLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yFxi1YN5; 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 7si490783oij.29.2020.02.21.00.31.01; Fri, 21 Feb 2020 00:31:13 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=yFxi1YN5; 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 S2387726AbgBUIRt (ORCPT + 99 others); Fri, 21 Feb 2020 03:17:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:55338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387722AbgBUIRq (ORCPT ); Fri, 21 Feb 2020 03:17:46 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 71E9F2468A; Fri, 21 Feb 2020 08:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273065; bh=UnMsQWUsQjYWat8/BAwihbk8GHrMfLjbO5UNSPoj6uE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yFxi1YN5QCoJQnf9dEjFhbeIFUN1Q9mYiPdH6IFp9kDBcGPuCm11s65a1cCfFjJlE immaQykOhA5s+P7TqzMvReAWngR6otrxnizB9t5ht59PFBszXYrj4Y++35EXbY/DG8 EHDhGw161/gvUBIkmtgeTJgDMUmW7U/0WGHiBNQA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Daniel Lezcano , Sasha Levin Subject: [PATCH 4.19 034/191] clocksource/drivers/bcm2835_timer: Fix memory leak of timer Date: Fri, 21 Feb 2020 08:40:07 +0100 Message-Id: <20200221072255.659726549@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 2052d032c06761330bca4944bb7858b00960e868 ] Currently when setup_irq fails the error exit path will leak the recently allocated timer structure. Originally the code would throw a panic but a later commit changed the behaviour to return via the err_iounmap path and hence we now have a memory leak. Fix this by adding a err_timer_free error path that kfree's timer. Addresses-Coverity: ("Resource Leak") Fixes: 524a7f08983d ("clocksource/drivers/bcm2835_timer: Convert init function to return error") Signed-off-by: Colin Ian King Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20191219213246.34437-1-colin.king@canonical.com Signed-off-by: Sasha Levin --- drivers/clocksource/bcm2835_timer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/bcm2835_timer.c b/drivers/clocksource/bcm2835_timer.c index 60da2537bef93..1082dcef17d17 100644 --- a/drivers/clocksource/bcm2835_timer.c +++ b/drivers/clocksource/bcm2835_timer.c @@ -134,7 +134,7 @@ static int __init bcm2835_timer_init(struct device_node *node) ret = setup_irq(irq, &timer->act); if (ret) { pr_err("Can't set up timer IRQ\n"); - goto err_iounmap; + goto err_timer_free; } clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff); @@ -143,6 +143,9 @@ static int __init bcm2835_timer_init(struct device_node *node) return 0; +err_timer_free: + kfree(timer); + err_iounmap: iounmap(base); return ret; -- 2.20.1