lkml.org 
[lkml]   [2003]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [CHECKER] 32 Memory Leaks on Error Paths
From
On Tue, Sep 23, 2003 at 01:14:30PM -0700, Chris Wright wrote:
> * David Yu Chen (dychen@stanford.edu) wrote:
> > [FILE: 2.6.0-test5/net/irda/irlmp.c]
> > [FUNC: irlmp_open_lsap]
> > [LINES: 161-183]
> > [VAR: self]
> > START -->
> > 161: self = kmalloc(sizeof(struct lsap_cb), GFP_ATOMIC);
> > 162: if (self == NULL) {
> > 163: ERROR("%s: can't allocate memory", __FUNCTION__);
> > 164: return NULL;
> > END -->
> > 183: ASSERT(notify->instance != NULL, return NULL;);
>
> Yes, this is a bug. Patch below. Jean, look ok?
>
> thanks,
> -chris

Yep, looks like the right thing. But, I would prefer a slighly
different fix. Would you mind moving the assert at the top of the
function ?
Just like this :
--------------------------------------------------------------------
--- linux/net/irda/irlmp.d1.c Tue Sep 23 13:19:37 2003
+++ linux/net/irda/irlmp.c Tue Sep 23 13:19:56 2003
@@ -146,6 +146,7 @@ struct lsap_cb *irlmp_open_lsap(__u8 sls
ASSERT(notify != NULL, return NULL;);
ASSERT(irlmp != NULL, return NULL;);
ASSERT(irlmp->magic == LMP_MAGIC, return NULL;);
+ ASSERT(notify->instance != NULL, return NULL;);

/* Does the client care which Source LSAP selector it gets? */
if (slsap_sel == LSAP_ANY) {
@@ -178,7 +179,6 @@ struct lsap_cb *irlmp_open_lsap(__u8 sls

init_timer(&self->watchdog_timer);

- ASSERT(notify->instance != NULL, return NULL;);
self->notify = *notify;

self->lsap_state = LSAP_DISCONNECTED;
--------------------------------------------------------------------
This is simpler and more efficient ;-)

Thanks...

Jean

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.221 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site