* [FIB]: removes a memset() call in tnode_new()
From: Eric Dumazet @ 2008-01-13 7:35 UTC (permalink / raw)
To: David S. Miller; +Cc: Linux Netdev List
[-- Attachment #1: Type: text/plain, Size: 158 bytes --]
tnode_alloc() already clears allocated memory, using kcalloc()
or alloc_pages(GFP_KERNEL|__GFP_ZERO, ...)
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
[-- Attachment #2: fib_trie.patch --]
[-- Type: text/plain, Size: 355 bytes --]
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index a418498..f26ba31 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -391,7 +391,6 @@ static struct tnode* tnode_new(t_key key, int pos, int bits)
struct tnode *tn = tnode_alloc(sz);
if (tn) {
- memset(tn, 0, sz);
tn->parent = T_TNODE;
tn->pos = pos;
tn->bits = bits;
^ permalink raw reply related
* Re: [PATCH 4/9] statistics improvements
From: David Miller @ 2008-01-13 5:44 UTC (permalink / raw)
To: shemminger; +Cc: robert.olsson, netdev, stephen.hemminger
In-Reply-To: <4789A29C.6080000@linux-foundation.org>
From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Sat, 12 Jan 2008 21:33:16 -0800
> The size field is added to /proc/net/fib_triestat that was the point.
Not from what I can see.
davem@sunset:~/src/GIT/net-2.6.25$ git grep -e "->size" net/ipv4/fib_trie.c
net/ipv4/fib_trie.c: t->size++;
net/ipv4/fib_trie.c: t->size--;
davem@sunset:~/src/GIT/net-2.6.25$ git grep -e "\.size" net/ipv4/fib_trie.c
davem@sunset:~/src/GIT/net-2.6.25$
Nothing uses the field, it is merely incremented and decremented.
trie_show_stats() and trie_show_usage() do not access this field.
^ permalink raw reply
* Re: [PATCH] fib_semantics: prevent long hash chains in access server config
From: David Miller @ 2008-01-13 5:38 UTC (permalink / raw)
To: bcrl; +Cc: netdev
In-Reply-To: <20080112185819.GA12775@kvack.org>
From: Benjamin LaHaise <bcrl@kvack.org>
Date: Sat, 12 Jan 2008 13:58:19 -0500
> This is a patch from a while ago that I'm resending. Basically, in
> access server configurations, a lot of routes have the same local ip
> address but on different devices. This fixes the long chains that
> result from not including the device index in the hash.
I'm not applying this for the same reason I didn't apply it last time.
Please listen to the reason this time, and do not resubmit this until
the problem with this patch is resolved.
The fib_dev is an attribute of the first nexthop, ie. the
fib_info->fib_nh[0] member.
There can be multiple nexthops.
It is pointless to salt the hash with one of the nexthop
device indexes if you do not also compare the index in the
hash lookup comparisons.
And guess why we don't do this? Because it's not part of
the key. Other aspects of the base fib_info and nexthops
provide the uniqueness, not the devindex of the first hop.
So you'll need to find another way to do this.
^ permalink raw reply
* Re: [PATCH 4/9] statistics improvements
From: Stephen Hemminger @ 2008-01-13 5:33 UTC (permalink / raw)
To: David Miller; +Cc: robert.olsson, netdev, stephen.hemminger
In-Reply-To: <20080112.205520.55747078.davem@davemloft.net>
David Miller wrote:
> From: Stephen Hemminger <shemminger@linux-foundation.org>
> Date: Fri, 11 Jan 2008 22:45:17 -0800
>
>
>> Turn the unused size field into a useful counter for the number
>> of routes.
>>
>> Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
>>
>
> It's not useful if nothing reports it's value. I'm dropping
> this.
>
> Unless you add code to provide this information via procfs
> or similar, better to just remove it.
>
The size field is added to /proc/net/fib_triestat that was the point.
^ permalink raw reply
* [PATCH v2] Documentation: add a guideline for hard_start_xmit method
From: Matti Linnanvuori @ 2008-01-13 5:33 UTC (permalink / raw)
To: jgarzik, netdev
From: Matti Linnanvuori <mattilinnanvuori@yahoo.com>
Add a guideline for hard_start_xmit method not to
modify SKB.
Signed-off-by: Matti Linnanvuori <mattilinnanvuori@yahoo.com>
---
--- a/Documentation/networking/driver.txt 2008-01-13 07:14:01.608291500 +0200
+++ b/Documentation/networking/driver.txt 2008-01-13 07:13:40.535421500 +0200
@@ -61,7 +61,9 @@
2) Do not forget to update netdev->trans_start to jiffies after
each new tx packet is given to the hardware.
-3) Do not forget that once you return 0 from your hard_start_xmit
+3) A hard_start_xmit method must not modify the shared parts of the SKB.
+
+4) Do not forget that once you return 0 from your hard_start_xmit
method, it is your driver's responsibility to free up the SKB
and in some finite amount of time.
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
^ permalink raw reply
* Re: [XFRM]: alg_key_len should be unsigned to avoid integer divides
From: David Miller @ 2008-01-13 5:32 UTC (permalink / raw)
To: dada1; +Cc: netdev
In-Reply-To: <4788F8FC.3010001@cosmosbay.com>
From: Eric Dumazet <dada1@cosmosbay.com>
Date: Sat, 12 Jan 2008 18:29:32 +0100
> alg_key_len is currently defined as 'signed int'. This unfortunatly leads
> to integer divides in several paths.
>
> Converting it to unsigned is safe and saves 208 bytes of text on i386.
>
> Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Applied.
I realigned the struct members in a follow-on changeset.
commit 7305e737926be49e09718df53f4285bf69cc3755
Author: David S. Miller <davem@davemloft.net>
Date: Sat Jan 12 21:31:29 2008 -0800
[XFRM]: Fix struct xfrm_algo code formatting.
Realign struct members.
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index f8507ee..9b5b00c 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -91,9 +91,9 @@ struct xfrm_replay_state
};
struct xfrm_algo {
- char alg_name[64];
+ char alg_name[64];
unsigned int alg_key_len; /* in bits */
- char alg_key[0];
+ char alg_key[0];
};
struct xfrm_stats {
^ permalink raw reply related
* Re: [PATCH 2/2] [HTB]: htb_classid is dead static inline
From: David Miller @ 2008-01-13 5:29 UTC (permalink / raw)
To: ilpo.jarvinen; +Cc: netdev
In-Reply-To: <12001388163255-git-send-email-ilpo.jarvinen@helsinki.fi>
From: "Ilpo_Järvinen" <ilpo.jarvinen@helsinki.fi>
Date: Sat, 12 Jan 2008 13:53:36 +0200
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Applied.
^ permalink raw reply
* Re: [PATCH 1/2] [NET] core/utils.c: digit2bin is dead static inline
From: David Miller @ 2008-01-13 5:28 UTC (permalink / raw)
To: ilpo.jarvinen; +Cc: netdev
In-Reply-To: <1200138816244-git-send-email-ilpo.jarvinen@helsinki.fi>
From: "Ilpo_Järvinen" <ilpo.jarvinen@helsinki.fi>
Date: Sat, 12 Jan 2008 13:53:35 +0200
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Applied.
^ permalink raw reply
* Re: [PATCH 9/9] fix sparse warnings
From: David Miller @ 2008-01-13 5:28 UTC (permalink / raw)
To: stephen.hemminger; +Cc: dada1, robert.olsson, netdev
In-Reply-To: <20080112130946.4d83eca7@deepthought>
From: Stephen Hemminger <stephen.hemminger@vyatta.com>
Date: Sat, 12 Jan 2008 13:09:46 -0800
> On Sat, 12 Jan 2008 12:16:13 +0100
> Eric Dumazet <dada1@cosmosbay.com> wrote:
>
> > [FIB]: Reduce text size of net/ipv4/fib_trie.o
> >
> > In struct tnode, we use two fields of 5 bits for 'pos' and 'bits'.
> > Switching to plain 'unsigned char' (8 bits) take the same space
> > because of compiler alignments, and reduce text size by 435 bytes
> > on i386.
> >
> > On i386 :
> > $ size net/ipv4/fib_trie.o.before_patch net/ipv4/fib_trie.o
> > text data bss dec hex filename
> > 13714 4 64 13782 35d6 net/ipv4/fib_trie.o.before
> > 13279 4 64 13347 3423 net/ipv4/fib_trie.o
> >
> > Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
> >
>
> I agree they should not have been bitfields in the first place.
Applied.
^ permalink raw reply
* Re: [PATCH 6/8] [NETFILTER] xt_policy.c: kill some bloat
From: David Miller @ 2008-01-13 5:26 UTC (permalink / raw)
To: kaber; +Cc: ilpo.jarvinen, netdev, netfilter-devel
In-Reply-To: <47890F03.5080503@trash.net>
From: Patrick McHardy <kaber@trash.net>
Date: Sat, 12 Jan 2008 20:03:31 +0100
> David Miller wrote:
> > From: "Ilpo_Järvinen" <ilpo.jarvinen@helsinki.fi>
> > Date: Sat, 12 Jan 2008 11:34:27 +0200
> >
> > Ilpo, please post netfilter patches to netfilter-devel,
> > CC:'ing Patrick McHardy.
> >
> > Patrick, please review, thanks.
>
> This looks fine to me, thanks Ilpo.
Applied, thanks.
^ permalink raw reply
* Re: [PATCH 9/9] fix sparse warnings
From: David Miller @ 2008-01-13 5:25 UTC (permalink / raw)
To: shemminger; +Cc: robert.olsson, netdev, stephen.hemminger
In-Reply-To: <20080112064646.659443238@linux-foundation.org>
From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 11 Jan 2008 22:45:22 -0800
> Make FIB TRIE go through sparse checker without warnings.
>
> Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
Also applied, thanks.
^ permalink raw reply
* Re: [PATCH 8/9] add statistics
From: David Miller @ 2008-01-13 5:23 UTC (permalink / raw)
To: shemminger; +Cc: robert.olsson, netdev, stephen.hemminger
In-Reply-To: <20080112064646.583836190@linux-foundation.org>
From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 11 Jan 2008 22:45:21 -0800
> The FIB TRIE code has a bunch of statistics, but the code is hidden
> behind an ifdef that was never implemented. Since it was dead code,
> it was broken as well.
>
> This patch fixes that by making it a config option.
>
> Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH 7/9] printk related cleanups
From: David Miller @ 2008-01-13 4:58 UTC (permalink / raw)
To: shemminger; +Cc: robert.olsson, netdev
In-Reply-To: <20080112064646.507015655@linux-foundation.org>
From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 11 Jan 2008 22:45:20 -0800
> printk related cleanups:
> * Get rid of unused printk wrappers.
> * Make bug checks into KERN_WARNING because KERN_DEBUG gets ignored
> * Turn one cryptic old message into something real
> * Make sure all messages have KERN_XXX
Applied, thanks.
^ permalink raw reply
* Re: [PATCH 6/9] : fib_insert_node cleanup
From: David Miller @ 2008-01-13 4:57 UTC (permalink / raw)
To: shemminger; +Cc: robert.olsson, netdev, stephen.hemminger
In-Reply-To: <20080112064646.432200237@linux-foundation.org>
From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 11 Jan 2008 22:45:19 -0800
> The only error from fib_insert_node is if memory allocation fails,
> so instead of passing by reference, just use the convention of returning
> NULL.
>
> Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
I'd be a hypocrite if I didn't apply this one :-)
Applied, thanks.
^ permalink raw reply
* Re: [PATCH 5/9] use %u for unsigned printfs
From: David Miller @ 2008-01-13 4:56 UTC (permalink / raw)
To: shemminger; +Cc: robert.olsson, netdev, stephen.hemminger
In-Reply-To: <20080112064646.356466158@linux-foundation.org>
From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 11 Jan 2008 22:45:18 -0800
> Use %u instead of %d when printing unsigned values.
>
> Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH 4/9] statistics improvements
From: David Miller @ 2008-01-13 4:55 UTC (permalink / raw)
To: shemminger; +Cc: robert.olsson, netdev, stephen.hemminger
In-Reply-To: <20080112064646.282104074@linux-foundation.org>
From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 11 Jan 2008 22:45:17 -0800
> Turn the unused size field into a useful counter for the number
> of routes.
>
> Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
It's not useful if nothing reports it's value. I'm dropping
this.
Unless you add code to provide this information via procfs
or similar, better to just remove it.
^ permalink raw reply
* Re: [PATCH 3/9] move size information to pr_debug()
From: David Miller @ 2008-01-13 4:53 UTC (permalink / raw)
To: shemminger; +Cc: robert.olsson, netdev, stephen.hemminger
In-Reply-To: <20080112064646.207183428@linux-foundation.org>
From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 11 Jan 2008 22:45:16 -0800
> The size of structures is a debug thing, not something that needs to
> be part of a /proc api.
>
> Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
I don't necessarily agree with this one, the size of the
structures is an important inherent attribute contributing
directly to memory usage and performance of the algorithms.
So knowing those values are necessary to diagnose problems.
^ permalink raw reply
* Re: [PATCH 2/9] get rid of unused revision element
From: David Miller @ 2008-01-13 4:50 UTC (permalink / raw)
To: shemminger; +Cc: robert.olsson, netdev, stephen.hemminger
In-Reply-To: <20080112064646.132747871@linux-foundation.org>
From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 11 Jan 2008 22:45:15 -0800
> The revision element must of been part of an earlier design,
> because currently it is set but never used.
>
> Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
Applied.
I suspect Robert wanted to play around with some generation
ID optimizations but never got around to it.
^ permalink raw reply
* Re: [PATCH 1/9] get rid of trie_init
From: David Miller @ 2008-01-13 4:49 UTC (permalink / raw)
To: shemminger; +Cc: robert.olsson, netdev, stephen.hemminger
In-Reply-To: <20080112064646.056241123@linux-foundation.org>
From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 11 Jan 2008 22:45:14 -0800
> trie_init is worthless it is just zeroing stuff that is already
> zero! Move the memset() down to make it obvious.
>
> Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
Applied.
^ permalink raw reply
* Re: [RFC PATCH 8/8] [PKTGEN]: uninline getCurUs
From: David Miller @ 2008-01-13 4:24 UTC (permalink / raw)
To: ilpo.jarvinen; +Cc: herbert, netdev
In-Reply-To: <Pine.LNX.4.64.0801121420220.19333@kivilampi-30.cs.helsinki.fi>
From: "Ilpo_Järvinen" <ilpo.jarvinen@helsinki.fi>
Date: Sat, 12 Jan 2008 14:59:50 +0200 (EET)
> ...Maybe I just fall-back to changing my last name, it's the only
> full-proof solution... ;-)
Don't do this! Otherwise I won't have a frequent test case to make
sure my patch applying scripts are working properly. :-))))
^ permalink raw reply
* Re: [RFC PATCH 8/8] [PKTGEN]: uninline getCurUs
From: David Miller @ 2008-01-13 4:22 UTC (permalink / raw)
To: herbert; +Cc: ilpo.jarvinen, netdev
In-Reply-To: <20080112121740.GA4555@gondor.apana.org.au>
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Sat, 12 Jan 2008 23:17:40 +1100
> Your emails are now using UTF-8 encoding but it's still declaring
> ISO-8859-1 as the charset. So you probably want to fix that up or
> your name may show up as Jävinen on the reader's screen.
Yes, for people using the GIT email patch applying tools, it might do
that. However I believe there are options to git-am and friends to
force it to put things into UTF-8.
I ran into some problems with encoding because I apply stuff by hand
using scripts I wrote.
But those problem won't happen any more for me.
I'm now saving the commit message and patch into files explicitly in
emacs, and verifying the coding (with "C-h C RET") and if it's wrong I
fix it before saving with "C-x RET f mule-utf-8"
Then I feed those into my patch applying scripts.
^ permalink raw reply
* Re: [PATCH net-2.6.25] [XFRM] Remove unused XFRM_STATE_VOID and typos (net/xfrm.h)
From: David Miller @ 2008-01-13 4:12 UTC (permalink / raw)
To: ramirose; +Cc: netdev
In-Reply-To: <eb3ff54b0801120337w2b49ef4bsfb805ac8d28dc712@mail.gmail.com>
From: "Rami Rosen" <ramirose@gmail.com>
Date: Sat, 12 Jan 2008 13:37:34 +0200
> In net/xfrm.h:
> - remove XFRM_STATE_VOID (not in use)
> - correct 3 typos
>
> Signed-off-by: Rami Rosen <ramirose@gmail.com>
XFRM_STATE_VOID is there so that a freshly initialized
object does not have a valid state. So we should not
remove this.
^ permalink raw reply
* Re: [PATCH/RFC] synchronize_rcu(): high latency on idle system
From: Stephen Hemminger @ 2008-01-13 1:52 UTC (permalink / raw)
To: Andi Kleen; +Cc: netdev, linux-kerne
In-Reply-To: <200801121935.58286.ak@suse.de>
On Sat, 12 Jan 2008 19:35:58 +0100
Andi Kleen <ak@suse.de> wrote:
> On Saturday 12 January 2008 18:51:35 Benjamin LaHaise wrote:
> > On Sat, Jan 12, 2008 at 03:37:59AM +0100, Andi Kleen wrote:
> > > > And yes, the
> > > > network stack shouldn't call synchronize_rcu() quite so much, but fixing that
> > > > is a little more involved.
> > >
> > > ... but the correct solution.
> >
> > There has to be at least 1 synchronize_rcu() or equivalent in the
> > unregister_netdev() path. I suspect the easiest way to fix it might be to
> > use call_rcu() to actually free the network device, as anything else will
> > limit performance of single threaded teardown (ie, when an l2tp daemon
> > gets terminated via kill -9). This means an API change that exposes
> > rcu for unregister_netdev().
>
> The call_rcu() could be in free_netdev() couldn't it?
I think it should be in netdev_unregister_kobject(). But that would
only get rid of one of the two calls to synchronize_rcu() in the unregister_netdev.
The other synchronize_rcu() is for qdisc's and not sure if that one can
be removed?
--
Stephen Hemminger <stephen.hemminger@vyatta.com>
^ permalink raw reply
* [PATCH 2/2] irda: avoid potential memory leak in irda_setsockopt()
From: Jesper Juhl @ 2008-01-13 0:34 UTC (permalink / raw)
To: Samuel Ortiz; +Cc: Dag Brattli, Jean Tourrilhes, LKML, Netdev, Jesper Juhl
There are paths through the irda_setsockopt() function where we return and
may or may not have allocated a new ias_obj but in any case have not used
it for anything yet and we end up leaking memory.
As far as I can tell, in the case where we didn't allocate a new ias_ob
but simply were planning to use one already available then we should not
free it before returning. But when we have allocated a brand new ias_obj
but have not yet used it or put it on any lists etc and then return,
that's a memory leak.
There are two cases:
1)
switch (optname) {
case IRLMP_IAS_SET:
...
if(ias_obj == (struct ias_object *) NULL) {
/* Create a new object */
--[alloc]--> ias_obj = irias_new_object(ias_opt->irda_class_name,
jiffies);
...
switch(ias_opt->irda_attrib_type) {
case IAS_OCT_SEQ:
/* Check length */
if(ias_opt->attribute.irda_attrib_octet_seq.len >
IAS_MAX_OCTET_STRING) {
kfree(ias_opt);
--[leak]--> return -EINVAL;
...
}
irias_insert_object(ias_obj);
The allocated object isn't referenced at all until we get outside the
inner switch, so clearly we leak it (if we took the path that allocated it
that is).
2)
The second case is the same as the above, except it's the default: case in
the inner switch instead of case IAS_OCT_SEQ:
default :
kfree(ias_opt);
return -EINVAL;
The way I propose to fix this is with a new variable that keeps track of
whether or not we found an existing ias_obj to use or if we took the
allocation path, then use that variable to determine if we should free
ias_obj before returning from the function.
I'm not very intimate with this code, so if there's a better solution I'd
very much like to hear it. It's also entirely possible that someone with
more knowledge of this code can prove that these cases can't actually ever
happen - if that's the case then please let me know.
This patch is meant to be applied on top of
[PATCH 1/2] irda: return -ENOMEM upon failure to allocate new ias_obj
The Coverity checker gets credit for pointing its finger towards this.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
af_irda.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index e33f0a5..352e8a7 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -1824,7 +1824,8 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
struct irda_sock *self = irda_sk(sk);
struct irda_ias_set *ias_opt;
struct ias_object *ias_obj;
- struct ias_attrib * ias_attr; /* Attribute in IAS object */
+ struct ias_attrib *ias_attr; /* Attribute in IAS object */
+ int alloc_new_obj = 0;
int opt;
IRDA_DEBUG(2, "%s(%p)\n", __FUNCTION__, self);
@@ -1885,6 +1886,7 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
kfree(ias_opt);
return -ENOMEM;
}
+ alloc_new_obj = 1;
}
/* Do we have the attribute already ? */
@@ -1908,6 +1910,8 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
if(ias_opt->attribute.irda_attrib_octet_seq.len >
IAS_MAX_OCTET_STRING) {
kfree(ias_opt);
+ if (alloc_new_obj)
+ kfree(ias_obj);
return -EINVAL;
}
/* Add an octet sequence attribute */
@@ -1936,6 +1940,8 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
break;
default :
kfree(ias_opt);
+ if (alloc_new_obj)
+ kfree(ias_obj);
return -EINVAL;
}
irias_insert_object(ias_obj);
^ permalink raw reply related
* [PATCH 1/2] irda: return -ENOMEM upon failure to allocate new ias_obj
From: Jesper Juhl @ 2008-01-13 0:34 UTC (permalink / raw)
To: Samuel Ortiz; +Cc: Dag Brattli, Jean Tourrilhes, LKML, Netdev, Jesper Juhl
irias_new_object() can fail its memory allocation and will return NULL in
that case. I believe the proper thing to do is to catch this, free the
ias_opt that was allocated earlier but won't be used and then return
-ENOMEM.
There are assertions further on that check for a NULL ias_obj, but I think
it's a lot nicer to simply return -ENOMEM to the caller here where we know
a memory allocation failed, rather than hitting an assertion later.
note: I don't have any means of actually testing this, so it has been
compile tested only.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
af_irda.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index d5e4dd7..e33f0a5 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -1881,6 +1881,10 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
/* Create a new object */
ias_obj = irias_new_object(ias_opt->irda_class_name,
jiffies);
+ if (!ias_obj) {
+ kfree(ias_opt);
+ return -ENOMEM;
+ }
}
/* Do we have the attribute already ? */
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox