linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang@pengutronix.de>
To: Julia Lawall <julia@diku.dk>
Cc: netdev@vger.kernel.org, devicetree-discuss@lists.ozlabs.org,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	Vitaly Bordug <vbordug@ru.mvista.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 1/2] drivers/net/fs_enet/fs_enet-main.c: Add of_node_put to avoid memory leak
Date: Sat, 4 Sep 2010 17:48:10 +0200	[thread overview]
Message-ID: <20100904154810.GB1762@pengutronix.de> (raw)
In-Reply-To: <1283595164-29146-1-git-send-email-julia@diku.dk>

[-- Attachment #1: Type: text/plain, Size: 2141 bytes --]

On Sat, Sep 04, 2010 at 12:12:43PM +0200, Julia Lawall wrote:
> In this case, a device_node structure is stored in another structure that
> is then freed without first decrementing the reference count of the
> device_node structure.
> 
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @r exists@
> expression x;
> identifier f;
> position p1,p2;
> @@
> 
> x@p1->f = \(of_find_node_by_path\|of_find_node_by_name\|of_find_node_by_phandle\|of_get_parent\|of_get_next_parent\|of_get_next_child\|of_find_compatible_node\|of_match_node\|of_find_node_by_type\|of_find_node_with_property\|of_find_matching_node\|of_parse_phandle\|of_node_get\)(...);
> ... when != of_node_put(x)
> kfree@p2(x)
> 
> @script:python@
> p1 << r.p1;
> p2 << r.p2;
> @@
> cocci.print_main("call",p1)
> cocci.print_secs("free",p2)
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>

Acked-by: Wolfram Sang <w.sang@pengutronix.de>

> 
> ---
>  drivers/net/fs_enet/fs_enet-main.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
> index d6e3111..d684f18 100644
> --- a/drivers/net/fs_enet/fs_enet-main.c
> +++ b/drivers/net/fs_enet/fs_enet-main.c
> @@ -1036,7 +1036,7 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev,
>  	ndev = alloc_etherdev(privsize);
>  	if (!ndev) {
>  		ret = -ENOMEM;
> -		goto out_free_fpi;
> +		goto out_put;
>  	}
>  
>  	SET_NETDEV_DEV(ndev, &ofdev->dev);
> @@ -1099,6 +1099,7 @@ out_cleanup_data:
>  out_free_dev:
>  	free_netdev(ndev);
>  	dev_set_drvdata(&ofdev->dev, NULL);
> +out_put:
>  	of_node_put(fpi->phy_node);
>  out_free_fpi:
>  	kfree(fpi);
> 
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2010-09-04 15:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-04 10:12 [PATCH 1/2] drivers/net/fs_enet/fs_enet-main.c: Add of_node_put to avoid memory leak Julia Lawall
2010-09-04 15:48 ` Wolfram Sang [this message]
2010-09-07  1:29 ` David Miller

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=20100904154810.GB1762@pengutronix.de \
    --to=w.sang@pengutronix.de \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=julia@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=vbordug@ru.mvista.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;
as well as URLs for NNTP newsgroup(s).