[<prev] [next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.1.00.0801130101510.2235@dragon.funnycrock.com>
Date: Sun, 13 Jan 2008 01:34:13 +0100 (CET)
From: Jesper Juhl <jesper.juhl@...il.com>
To: Samuel Ortiz <samuel@...tiz.org>
cc: Dag Brattli <dagb@...uit.no>, Jean Tourrilhes <jt@....hp.com>,
LKML <linux-kernel@...r.kernel.org>,
Netdev <netdev@...r.kernel.org>,
Jesper Juhl <jesper.juhl@...il.com>
Subject: [PATCH 1/2] irda: return -ENOMEM upon failure to allocate new
ias_obj
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@...il.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 ? */
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists