From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: andrew@lunn.ch, vivien.didelot@savoirfairelinux.com,
f.fainelli@gmail.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: [PATCH] net: dsa: loop: Free resources if initialization is deferred
Date: Wed, 10 May 2017 06:15:03 +0200 [thread overview]
Message-ID: <20170510041503.29363-1-christophe.jaillet@wanadoo.fr> (raw)
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
next reply other threads:[~2017-05-10 4:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-10 4:15 Christophe JAILLET [this message]
2017-05-10 4:30 ` [PATCH] net: dsa: loop: Free resources if initialization is deferred Julia Lawall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170510041503.29363-1-christophe.jaillet@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@savoirfairelinux.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox