[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <205e2b3a-2934-f5d0-6b12-59beee0d58fa@web.de>
Date: Wed, 30 Oct 2019 21:50:17 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: linux-tegra@...r.kernel.org, Coccinelle <cocci@...teme.lip6.fr>
Cc: JC Kuo <jckuo@...dia.com>, Jonathan Hunter <jonathanh@...dia.com>,
Kishon Vijay Abraham I <kishon@...com>,
Thierry Reding <treding@...dia.com>,
LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org, Kangjie Lu <kjlu@....edu>,
Navid Emamdoost <emamd001@....edu>,
Stephen McCamant <smccaman@....edu>,
Dan Carpenter <dan.carpenter@...cle.com>,
YueHaibing <yuehaibing@...wei.com>
Subject: Re: drivers/phy/tegra: Completion for exception handling in probe
functions with SmPL?
> But I stumble on another unexpected test result.
I got more promising results by the following transformation approach.
@adjustment exists@
expression object;
identifier exit;
@@
object = kzalloc(...)
...
if (...)
-{ kfree(object);
goto
- exit
+ release_memory
;
-}
... when any
device_unregister(...);
-exit
+release_memory
:
+kfree(object);
return ERR_PTR(...);
The scope property of such a SmPL rule occasionally needs also more
software development attention.
https://github.com/coccinelle/coccinelle/blob/ed1eb8e06f800739d3992158d36945c0c4c6f0c7/docs/manual/cocci_syntax.tex#L860
I observe that the pretty-printing for the generated source code will need
further improvements (according to the Linux coding style).
Example:
elfring@...ne:~/Projekte/Linux/next-patched> spatch drivers/phy/tegra/xusb-tegra186.c ~/Projekte/Coccinelle/janitor/complete_exception_handling_in_probe_functions6.cocci
…
@@ -461,10 +461,8 @@ tegra186_usb2_pad_probe(struct tegra_xus
pad->soc = soc;
err = tegra_xusb_pad_init(pad, padctl, np);
- if (err < 0) {
- kfree(usb2);
- goto out;
- }
+ if (err < 0)
+ goto release_memory;
priv->usb2_trk_clk = devm_clk_get(&pad->dev, "trk");
if (IS_ERR(priv->usb2_trk_clk)) {
@@ -483,7 +481,8 @@ tegra186_usb2_pad_probe(struct tegra_xus
unregister:
device_unregister(&pad->dev);
-out:
+release_memory :
+kfree(usb2);
return ERR_PTR(err);
}
…
How reasonable do you find the presented update suggestion?
Regards,
Markus
Powered by blists - more mailing lists