Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1638548 > unrolled thread

[PATCH] net: dsa: loop: Free resources if initialization is deferred

Started byChristophe JAILLET <christophe.jaillet@wanadoo.fr>
First post2017-05-10 06:20 +0200
Last post2017-05-10 06:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net: dsa: loop: Free resources if initialization is deferred Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-05-10 06:20 +0200
    Re: [PATCH] net: dsa: loop: Free resources if initialization is  deferred Julia Lawall <julia.lawall@lip6.fr> - 2017-05-10 06:40 +0200

#1638548 — [PATCH] net: dsa: loop: Free resources if initialization is deferred

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2017-05-10 06:20 +0200
Subject[PATCH] net: dsa: loop: Free resources if initialization is deferred
Message-ID<tFrgt-3Tb-5@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1638555 — Re: [PATCH] net: dsa: loop: Free resources if initialization is deferred

FromJulia Lawall <julia.lawall@lip6.fr>
Date2017-05-10 06:40 +0200
SubjectRe: [PATCH] net: dsa: loop: Free resources if initialization is deferred
Message-ID<tFrzP-4b3-11@gated-at.bofh.it>
In reply to#1638548

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
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web