* [PATCH] net: dsa: loop: Free resources if initialization is deferred
@ 2017-05-10 4:15 Christophe JAILLET
2017-05-10 4:30 ` Julia Lawall
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2017-05-10 4:15 UTC (permalink / raw)
To: andrew, vivien.didelot, f.fainelli
Cc: netdev, linux-kernel, kernel-janitors, Christophe JAILLET
Free some devm'allocated memory in case of deferred driver initialization.
This avoid to waste some memory in such a case.
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/net/dsa/dsa_loop.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index a19e1781e9bb..557afb418320 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -260,8 +260,11 @@ static int dsa_loop_drv_probe(struct mdio_device *mdiodev)
return -ENOMEM;
ps->netdev = dev_get_by_name(&init_net, pdata->netdev);
- if (!ps->netdev)
+ if (!ps->netdev) {
+ devm_kfree(&mdiodev->dev, ps);
+ devm_kfree(&mdiodev->dev, ds);
return -EPROBE_DEFER;
+ }
pdata->cd.netdev[DSA_LOOP_CPU_PORT] = &ps->netdev->dev;
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: dsa: loop: Free resources if initialization is deferred
2017-05-10 4:15 [PATCH] net: dsa: loop: Free resources if initialization is deferred Christophe JAILLET
@ 2017-05-10 4:30 ` Julia Lawall
0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2017-05-10 4:30 UTC (permalink / raw)
To: Christophe JAILLET
Cc: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel,
kernel-janitors
On Wed, 10 May 2017, Christophe JAILLET wrote:
> Free some devm'allocated memory in case of deferred driver initialization.
> This avoid to waste some memory in such a case.
I really think it would be helpful to mention the special behavior of
-EPROBE_DEFER. It doesn't take much space, and it coud be helpful to
someone in the future.
julia
>
> Suggested-by: Joe Perches <joe@perches.com>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/net/dsa/dsa_loop.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
> index a19e1781e9bb..557afb418320 100644
> --- a/drivers/net/dsa/dsa_loop.c
> +++ b/drivers/net/dsa/dsa_loop.c
> @@ -260,8 +260,11 @@ static int dsa_loop_drv_probe(struct mdio_device *mdiodev)
> return -ENOMEM;
>
> ps->netdev = dev_get_by_name(&init_net, pdata->netdev);
> - if (!ps->netdev)
> + if (!ps->netdev) {
> + devm_kfree(&mdiodev->dev, ps);
> + devm_kfree(&mdiodev->dev, ds);
> return -EPROBE_DEFER;
> + }
>
> pdata->cd.netdev[DSA_LOOP_CPU_PORT] = &ps->netdev->dev;
>
> --
> 2.11.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-10 4:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-10 4:15 [PATCH] net: dsa: loop: Free resources if initialization is deferred Christophe JAILLET
2017-05-10 4:30 ` Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).