* [PATCH] [IrDA] af_irda memory leak fixes
@ 2008-01-18 7:53 Samuel Ortiz
2008-01-20 0:23 ` Jesper Juhl
[not found] ` <20080118075322.GB3063-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org>
0 siblings, 2 replies; 3+ messages in thread
From: Samuel Ortiz @ 2008-01-18 7:53 UTC (permalink / raw)
To: David S. Miller; +Cc: irda-users, netdev, Jesper Juhl
Hi Dave,
Here goes an IrDA patch against your latest net-2.6 tree.
This patch fixes some af_irda memory leaks.
It also checks for irias_new_obect() return value.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Samuel Ortiz <samuel@sortiz.org>
---
net/irda/af_irda.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
Index: net-2.6-davem/net/irda/af_irda.c
===================================================================
--- net-2.6-davem.orig/net/irda/af_irda.c 2008-01-17 06:00:10.000000000 +0100
+++ net-2.6-davem/net/irda/af_irda.c 2008-01-18 08:37:36.000000000 +0100
@@ -802,12 +802,18 @@
}
#endif /* CONFIG_IRDA_ULTRA */
+ self->ias_obj = irias_new_object(addr->sir_name, jiffies);
+ if (self->ias_obj == NULL)
+ return -ENOMEM;
+
err = irda_open_tsap(self, addr->sir_lsap_sel, addr->sir_name);
- if (err < 0)
+ if (err < 0) {
+ kfree(self->ias_obj->name);
+ kfree(self->ias_obj);
return err;
+ }
/* Register with LM-IAS */
- self->ias_obj = irias_new_object(addr->sir_name, jiffies);
irias_add_integer_attrib(self->ias_obj, "IrDA:TinyTP:LsapSel",
self->stsap_sel, IAS_KERNEL_ATTR);
irias_insert_object(self->ias_obj);
@@ -1825,7 +1831,7 @@
struct irda_ias_set *ias_opt;
struct ias_object *ias_obj;
struct ias_attrib * ias_attr; /* Attribute in IAS object */
- int opt;
+ int opt, free_ias = 0;
IRDA_DEBUG(2, "%s(%p)\n", __FUNCTION__, self);
@@ -1881,11 +1887,20 @@
/* Create a new object */
ias_obj = irias_new_object(ias_opt->irda_class_name,
jiffies);
+ if (ias_obj == NULL) {
+ kfree(ias_opt);
+ return -ENOMEM;
+ }
+ free_ias = 1;
}
/* Do we have the attribute already ? */
if(irias_find_attrib(ias_obj, ias_opt->irda_attrib_name)) {
kfree(ias_opt);
+ if (free_ias) {
+ kfree(ias_obj->name);
+ kfree(ias_obj);
+ }
return -EINVAL;
}
@@ -1904,6 +1919,11 @@
if(ias_opt->attribute.irda_attrib_octet_seq.len >
IAS_MAX_OCTET_STRING) {
kfree(ias_opt);
+ if (free_ias) {
+ kfree(ias_obj->name);
+ kfree(ias_obj);
+ }
+
return -EINVAL;
}
/* Add an octet sequence attribute */
@@ -1932,6 +1952,10 @@
break;
default :
kfree(ias_opt);
+ if (free_ias) {
+ kfree(ias_obj->name);
+ kfree(ias_obj);
+ }
return -EINVAL;
}
irias_insert_object(ias_obj);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [IrDA] af_irda memory leak fixes
2008-01-18 7:53 [PATCH] [IrDA] af_irda memory leak fixes Samuel Ortiz
@ 2008-01-20 0:23 ` Jesper Juhl
[not found] ` <20080118075322.GB3063-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org>
1 sibling, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2008-01-20 0:23 UTC (permalink / raw)
To: Samuel Ortiz; +Cc: David S. Miller, irda-users, netdev
On 18/01/2008, Samuel Ortiz <samuel@sortiz.org> wrote:
> Hi Dave,
>
> Here goes an IrDA patch against your latest net-2.6 tree.
>
> This patch fixes some af_irda memory leaks.
> It also checks for irias_new_obect() return value.
>
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
> Signed-off-by: Samuel Ortiz <samuel@sortiz.org>
...
Looks good Samuel.
Thank you for improving on my original suggested patch.
Now let's hope someone queues it up for mainline :)
--
Jesper Juhl <jesper.juhl@gmail.com>
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [IrDA] af_irda memory leak fixes
[not found] ` <20080118075322.GB3063-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org>
@ 2008-01-21 0:58 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2008-01-21 0:58 UTC (permalink / raw)
To: samuel-jcdQHdrhKHMdnm+yROfE0A
Cc: irda-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w, netdev-u79uwXL29TY76Z2rM5mHXA
From: Samuel Ortiz <samuel-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org>
Date: Fri, 18 Jan 2008 08:53:22 +0100
> Hi Dave,
>
> Here goes an IrDA patch against your latest net-2.6 tree.
>
> This patch fixes some af_irda memory leaks.
> It also checks for irias_new_obect() return value.
>
> Signed-off-by: Jesper Juhl <jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Samuel Ortiz <samuel-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org>
Applied, thanks Sam.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-01-21 0:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-18 7:53 [PATCH] [IrDA] af_irda memory leak fixes Samuel Ortiz
2008-01-20 0:23 ` Jesper Juhl
[not found] ` <20080118075322.GB3063-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org>
2008-01-21 0:58 ` David Miller
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).