Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp253155ybc; Tue, 12 Nov 2019 00:35:34 -0800 (PST) X-Google-Smtp-Source: APXvYqwb9OjQuq4DFKbHdour+dZQvSGoUYhfj8ANTjpiC7UQ0Z3eb54txbgVcU0my6ou5wmRiX/R X-Received: by 2002:a50:8a88:: with SMTP id j8mr32548573edj.35.1573547734185; Tue, 12 Nov 2019 00:35:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573547734; cv=none; d=google.com; s=arc-20160816; b=Bs6P2dKZUcYSiqnklguhYbAciJ0Qk4oRjJCE3utDNf+1QpNJ0thDgXFhB3C6mfM6qH WlmWXbvGGnDP3Pv9EqXtoIccSuAhU9gSxVtmthCowoMJYCLpV8lTJb6xiHn8l8KO44hE VrLu39mg9MwIhDk9f0JhtN3oA04jqjKv6SeswZnaWyZBLqxkzsqEYWKPSuHDZ6hUyVIh IDxwcfvtxX3VgXxdyASFpAy+NmnD9oLkC8X0ikMqJML2GjOsVSB2SyuQXhl0+HKuw+58 IxaAMSalcoGngZ0klCH7izinW6rHmF5rD+FV7JQFV7DI4wVdSN6+2VHN+DsU/aIRzStb SF7w== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=MTG7lQ0u9d8+q6rZMou9pMrXlqU/RMiDOcUJ4lZKiNI=; b=qNmIr1EaIn2nqziZh3+vyFvodg0hUUGqLxmul7cYEy9R9kvQpM8MQTZuJA5PSegWov eS7iKgO4c9L+7fRi6xJbg/6lD/JIHCMZ8pyvTkEBIYScK7jaV11V4f7CySiM5PTTbIJf pP1zJW6qptOdWEZMqZb6CaQVxUPMMPCLlX+vMzb2B3kBa3NXCEbG9fA6xuTzm80Hpia3 4U/8796xJVbHuU3uuRDi5pQdqUg0bvdE1zpuks2m7+LZ8LRvel6aTCGcgVsMswxgPW27 yFx8Bz7mz96VTGsALFpylOaF19nkeuapu0LRsu35myxJ2/SGFeIhhkJmhYb32nJB13Od dR1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=CdDTpHJF; 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 q18si13209311eda.291.2019.11.12.00.35.09; Tue, 12 Nov 2019 00:35:34 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=CdDTpHJF; 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 S1727025AbfKLIed (ORCPT + 99 others); Tue, 12 Nov 2019 03:34:33 -0500 Received: from mail-oi1-f195.google.com ([209.85.167.195]:35770 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbfKLIec (ORCPT ); Tue, 12 Nov 2019 03:34:32 -0500 Received: by mail-oi1-f195.google.com with SMTP id n16so14089970oig.2 for ; Tue, 12 Nov 2019 00:34:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=MTG7lQ0u9d8+q6rZMou9pMrXlqU/RMiDOcUJ4lZKiNI=; b=CdDTpHJF5JfhHDfSz4685fIPM0bW1Po430XfabG9F39pJJ1M9kCJeqGRakUVSC+FLC tT8Vos+VLGJcTMF0Sb1FEJtfUC0msCmnXmvPehTqz0iJYxwaGKWSN/j1cIbr07RzNQHs H5SlgF0t/HyHHC/YDR1W/r3rulnzQmYVK56eZvmgcUwREDnf60xguJnI18NNXp0Sh5GD j0lVfM/Q1du8kbgLkazEg4HXI6gmX5A0tYsNGm8wI1Nc9BRWeUGgIOh1dBx+XLO12fhU DwqlDy022kjhZFw+BQthvhXTui3Z06Aq+ubLFo4UmJYb+6zCs+YUAIZy/SiCfXvvmp4y CfLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=MTG7lQ0u9d8+q6rZMou9pMrXlqU/RMiDOcUJ4lZKiNI=; b=GKULl4Yp5+Cbk6LNSLm3IcfzFlLYfNIpzq8o2MrcL0AqSPUsFUf2SwayOrFwRvYmyJ 5NpOzeOlSZ6ihH5j364NnaJLTqQ2WpRPTKMtO8dBwvJ9DG5rMGKWCXbVNwC9rYmsPsY+ kHWCsSl/K7feJ5m8fI3EZV+LCMbLRUVQzgijcWxQy0MSlHN5XgeepwP5uNQNNYQMiEM9 tuNLLmexxbbvVG6oURZePN0t3zFmVlLR+06io6cO8ssNvCIuibIVXjz3YcKwDOP9m1+M qRxx4cZklRLfJFlcZBfPJ/Y8IpFQhBGg5DBPaPFdmrOev/GLUti3+zQ/jMLWPArlVWDC pMGA== X-Gm-Message-State: APjAAAWOkm8LV4dwQtWpUspXS6eFrpwiwuen79VkWkiI5JJRy4k+aRhy Zf1hha5/qhKARFiZOj1NuErdpChaj2VDQIoLwO1rpw== X-Received: by 2002:a05:6808:9a1:: with SMTP id e1mr2995041oig.175.1573547671896; Tue, 12 Nov 2019 00:34:31 -0800 (PST) MIME-Version: 1.0 References: <20191109155836.223635-1-colin.king@canonical.com> In-Reply-To: From: Bartosz Golaszewski Date: Tue, 12 Nov 2019 09:34:21 +0100 Message-ID: Subject: Re: [PATCH] clocksource/drivers/davinci: fix memory leak on clockevent on error return To: Thomas Gleixner Cc: Daniel Lezcano , Colin King , LKML , kernel-janitors@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org wt., 12 lis 2019 o 00:37 Thomas Gleixner napisa=C5=82(= a): > > Bartosz, > > On Sun, 10 Nov 2019, Bartosz Golaszewski wrote: > > sob., 9 lis 2019 o 16:58 Colin King napisa= =C5=82(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 cl= ockevents") > > > 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/clocksourc= e/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. Fair enough. Acked-by: Bartosz Golaszewski > > 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