Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6828996ybx; Mon, 11 Nov 2019 15:40:36 -0800 (PST) X-Google-Smtp-Source: APXvYqyTWfWG8R8DO+PYMP76/yaP+4jSecGcNB4BZMO75LmcZm+nKoeuksynF7BHKifdMlOnItyS X-Received: by 2002:a05:6402:1250:: with SMTP id l16mr1497441edw.219.1573515636448; Mon, 11 Nov 2019 15:40:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573515636; cv=none; d=google.com; s=arc-20160816; b=GDRPt2QsXZSCCAQAqUIn0gqIhxKVOfAzjrE9UiIrkoCsD2+1G0aHtsMPdRRUK+IXim aCJMaOxTr2d6tX3vIcfWnfIvA14lVIqYq0YNI/X+EWcM1nuRe2WcqH44nNJzBu0zLnuW LE2RuEVQTFub/bfAnKCUkamisjYyHuNN9h+HN05E7654vI32RU6AFYyMynybVcUkpid+ 2aSaO9pFYPiT5jySFw0+ikxGshKxtZEXR664tiy+gCoYFPKfOTjk6Vy4WXPuDWniNIri tzMW6u0zRMTRTOcZZH1JeEZ9RcB2oAjPZ6flfFhRP2LOqoSM0c6pD7p/RoQ61/K/Cj5K 6lnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=mL4dBeceGiPvP38crrZ79m0Q4M7uXU8LZgNxmFpKF7w=; b=iEIcJOh/BuxdUGpQIqZBh/VRQpp9LBa35VITkTiUTdk1AQAZB1qLlEr2mrI0yeTqeB 0UG94amWO3vrNwhQlBWQhvfJUVmPkS1nQ+PIXAelZnvpOB0UFLUcYRFhxARHlWmOESZC RDpzQtcNJnrzPZnqKW0x2hYM9EH+gp/Osb5dpIuFQP7VRLqwxtB24kGMdpJSjzojuBoc dNUpOoHF3duvDT6ObKQRbsT6bLFaWgss0FyyS+axxiV46a60f7dmCj+/RhwYLmL1QCeU LlLcti/ktMXoFR5av4QmRfpZhrsKcHroOBBMadgvkJmoPQvM/Ds6/jbCUgSr5rHxHr+m BLHw== 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 d26si9962796ejr.361.2019.11.11.15.40.12; Mon, 11 Nov 2019 15:40:36 -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; 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 S1727265AbfKKXhr (ORCPT + 99 others); Mon, 11 Nov 2019 18:37:47 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:60246 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726915AbfKKXhr (ORCPT ); Mon, 11 Nov 2019 18:37:47 -0500 Received: from p5b06da22.dip0.t-ipconnect.de ([91.6.218.34] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iUJFe-0001gT-0H; Tue, 12 Nov 2019 00:37:42 +0100 Date: Tue, 12 Nov 2019 00:37:41 +0100 (CET) From: Thomas Gleixner To: Bartosz Golaszewski cc: Daniel Lezcano , Colin King , LKML , kernel-janitors@vger.kernel.org Subject: Re: [PATCH] clocksource/drivers/davinci: fix memory leak on clockevent on error return In-Reply-To: Message-ID: References: <20191109155836.223635-1-colin.king@canonical.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1927344373-1573515462=:1833" X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1927344373-1573515462=:1833 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Bartosz, On Sun, 10 Nov 2019, Bartosz Golaszewski wrote: > sob., 9 lis 2019 o 16:58 Colin King napisaƂ(a): > > > > From: Colin Ian King > > > > In the case where request_irq fails, the return path does not kfree > > clockevent and hence we have a memory leak. Fix this by kfree'ing s/we have/creates/ or whatever verb you prefer. > > clockevent before returning. > > > > Addresses-Coverity: ("Resource leak") > > Fixes: 721154f972aa ("clocksource/drivers/davinci: Add support for clockevents") > > Signed-off-by: Colin Ian King > > --- > > drivers/clocksource/timer-davinci.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/clocksource/timer-davinci.c b/drivers/clocksource/timer-davinci.c > > index 62745c962049..910d4d2f0d64 100644 > > --- a/drivers/clocksource/timer-davinci.c > > +++ b/drivers/clocksource/timer-davinci.c > > @@ -299,6 +299,7 @@ int __init davinci_timer_register(struct clk *clk, > > "clockevent/tim12", clockevent); > > if (rv) { > > pr_err("Unable to request the clockevent interrupt"); > > + kfree(clockevent); > > return rv; > > } > > > > -- > > 2.20.1 > > > > Hi Daniel, > > this is what I think the third time someone tries to "fix" this > driver's "memory leaks". I'm not sure what the general approach in > clocksource is but it doesn't make sense to free resources on > non-recoverable errors, does it? Should I add a comment about it or > you'll just take those "fixes" to stop further such submissions? There are two ways to deal with that: 1) If the error is really unrecoverable, panic right there. No point to continue. 2) If there is even a minimal chance to survive, free the memory and return. Adding a comment is just a useless non-option. Thanks, tglx --8323329-1927344373-1573515462=:1833--