2006-03-18 23:44:54

by Jesper Juhl

[permalink] [raw]
Subject: [PATCH] cleanup for net/tipc/name_distr.c::tipc_named_node_up()


Small cleanup patch for net/tipc/name_distr.c::tipc_named_node_up()

Patch does the following:

- Change a few pointer assignments from 0 to NULL (makes sparse happy).
- Move a few variable assignment outside the tipc_nametbl_lock lock.
- Make sure to free the allocated buffer before returning so we don't leak.


Note: patch is compile tested only and I'm not familiar with this code, so
please check my changes carefully.


Signed-off-by: Jesper Juhl <[email protected]>
---

net/tipc/name_distr.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)

--- linux-2.6.16-rc6-orig/net/tipc/name_distr.c 2006-03-12 14:19:18.000000000 +0100
+++ linux-2.6.16-rc6/net/tipc/name_distr.c 2006-03-19 00:36:41.000000000 +0100
@@ -168,17 +168,17 @@ void tipc_named_withdraw(struct publicat
void tipc_named_node_up(unsigned long node)
{
struct publication *publ;
- struct distr_item *item = 0;
- struct sk_buff *buf = 0;
+ struct distr_item *item = NULL;
+ struct sk_buff *buf = NULL;
u32 left = 0;
u32 rest;
u32 max_item_buf;

assert(in_own_cluster(node));
- read_lock_bh(&tipc_nametbl_lock);
max_item_buf = TIPC_MAX_USER_MSG_SIZE / ITEM_SIZE;
max_item_buf *= ITEM_SIZE;
rest = publ_cnt * ITEM_SIZE;
+ read_lock_bh(&tipc_nametbl_lock);

list_for_each_entry(publ, &publ_root, local_list) {
if (!buf) {
@@ -200,10 +200,11 @@ void tipc_named_node_up(unsigned long no
"<%u.%u.%u>\n", tipc_zone(node),
tipc_cluster(node), tipc_node(node));
tipc_link_send(buf, node, node);
- buf = 0;
+ buf = NULL;
}
}
exit:
+ kfree_skb(buf);
read_unlock_bh(&tipc_nametbl_lock);
}





2006-03-22 09:56:13

by Per Liden

[permalink] [raw]
Subject: Re: [PATCH] cleanup for net/tipc/name_distr.c::tipc_named_node_up()

On Sun, 19 Mar 2006, Jesper Juhl wrote:

> Small cleanup patch for net/tipc/name_distr.c::tipc_named_node_up()

Not sure if you followed the discussion on the tipc mailinglist, so here's
a short summary.

> Patch does the following:
>
> - Change a few pointer assignments from 0 to NULL (makes sparse happy).

Ok.

> - Move a few variable assignment outside the tipc_nametbl_lock lock.

Ok.

> - Make sure to free the allocated buffer before returning so we don't leak.

The additional kfree_skb() looks incorrect. If a buffer if allocated it
will later be released by tipc_link_send().

/Per

2006-03-26 11:35:39

by Jesper Juhl

[permalink] [raw]
Subject: Re: [PATCH] cleanup for net/tipc/name_distr.c::tipc_named_node_up()

On 3/22/06, Per Liden <[email protected]> wrote:
> On Sun, 19 Mar 2006, Jesper Juhl wrote:
>
> > Small cleanup patch for net/tipc/name_distr.c::tipc_named_node_up()
>
> Not sure if you followed the discussion on the tipc mailinglist, so here's
> a short summary.
>
I don't read the tipc mailing list, no.


> > Patch does the following:
> >
> > - Change a few pointer assignments from 0 to NULL (makes sparse happy).
>
> Ok.
>
> > - Move a few variable assignment outside the tipc_nametbl_lock lock.
>
> Ok.
>

Do you want a new patch with just these bits in it or will you take
care of it yourself?


> > - Make sure to free the allocated buffer before returning so we don't leak.
>
> The additional kfree_skb() looks incorrect. If a buffer if allocated it
> will later be released by tipc_link_send().
>
I see. Then that bit is indeed incorrect.

--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html

2006-03-27 12:13:29

by Per Liden

[permalink] [raw]
Subject: Re: [PATCH] cleanup for net/tipc/name_distr.c::tipc_named_node_up()

On Sun, 26 Mar 2006, Jesper Juhl wrote:

[...]
> > > Patch does the following:
> > >
> > > - Change a few pointer assignments from 0 to NULL (makes sparse happy).
> >
> > Ok.
> >
> > > - Move a few variable assignment outside the tipc_nametbl_lock lock.
> >
> > Ok.
> >
>
> Do you want a new patch with just these bits in it or will you take
> care of it yourself?

The first one was has already been fixed with another patch that's in
Linus tree right now. The second one is borderline-cosmetic so I'll fix
that the next time I'm making changes in that area.

/Per