netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* leak in netlink_dump()?
@ 2002-11-13 19:53 Thomas Graf
  2002-11-19  2:22 ` jamal
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Graf @ 2002-11-13 19:53 UTC (permalink / raw)
  To: netdev

Hello!

Used Kernel: 2.4.18 (same for 2.4.19pre6)

I think I've found a memory leak in netlink_dump (af_netlink.c):

the netlink callback (sk->protinfo.af_netlink->cb) is allocated
in the calling funtion netlink_dump_start and is not freed
after the call to netlink_dump.

    ...

    netlink_dump.len = cb->dump(skb, cb);

    len = cb->dump(skb, cb);

    if (len > 0) {
        spin_unlock(&sk->protinfo.af_netlink->cb_lock);
        skb_queue_tail(&sk->receive_queue, skb);
        sk->data_ready(sk, len);
        
        /*
         * Isn't a netlink_destroy_callback(cb) missing here?
         */

        return 0;
    }

    ...

    netlink_destroy_callback(cb);   /* cb gets freed here */
    sock_put(sk);
    return 0;
}


The only other call to netlink_destroy_callback is in
netlink_release which is called from sock_release which is
called if the socket gets closed.

>From my point of view, this is a memory leak, but I'm new to
kernel code and I might be telling shit.

-- 
Thomas GRAF

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: leak in netlink_dump()?
  2002-11-13 19:53 leak in netlink_dump()? Thomas Graf
@ 2002-11-19  2:22 ` jamal
  0 siblings, 0 replies; 2+ messages in thread
From: jamal @ 2002-11-19  2:22 UTC (permalink / raw)
  To: Thomas Graf; +Cc: netdev



On Wed, 13 Nov 2002, Thomas Graf wrote:

> Hello!
>
> Used Kernel: 2.4.18 (same for 2.4.19pre6)
>
> I think I've found a memory leak in netlink_dump (af_netlink.c):
>
> the netlink callback (sk->protinfo.af_netlink->cb) is allocated
> in the calling funtion netlink_dump_start and is not freed
> after the call to netlink_dump.
>

It shouldnt be. The callback is only destroyed when the dump is complete
i.e nothing to dump anymore (skb->len == 0)

> From my point of view, this is a memory leak, but I'm new to
> kernel code and I might be telling shit.

Look carefully at places where netlink_dump is being invoked from and
youll get it.

cheers,
jamal

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-11-19  2:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-13 19:53 leak in netlink_dump()? Thomas Graf
2002-11-19  2:22 ` jamal

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).