mxc_fec: put freed pointers to NULL to avoid problems with further free() calls.
PATCH 2/2 mxc_fec: put freed pointers to NULL to avoid problems with further free() calls.
If a free() call is used on an already freed pointer we run into stability problems.
Put all pointers to NULL after freeing to avoid this problem.
Tested on i.MX27 Litekit board with eldk-2.0 toolchain.
--
drivers/net/fec_mxc.c +3 -0
@@ -444,6 +444,7 @@ static int fec_init(struct eth_device *dev, bd_t* bd)*/ if (fec_rbd_init (fec,FEC_RBD_NUM ,FEC_MAX_PKT_SIZE ) <0 ) {free (fec->base_ptr); + fec->base_ptr =NULL ;return -ENOMEM ; }fec_tbd_init (fec);
@@ -492,7 +493,9 @@ static void fec_halt(struct eth_device *dev) fec->rbd_index =0 ; fec->tbd_index =0 ;free (fec->rdb_ptr); + fec->rdb_ptr =NULL ;free (fec->base_ptr); + fec->base_ptr =NULL ;debug ("eth_halt: done\n" ); }
Signature · 7 lines
Javier Martin Vista Silicon S.L. CDTUC - FASE C - Oficina S-345 Avda de los Castros s/n 39005- Santander. Cantabria. Spain +34 942 25 32 60 www.vista-silicon.com
PATCH 2/2 mxc_fec: put freed pointers to NULL to avoid problems with further free() calls.
Dear javier Martin,
Quoted 2 lines · In message <[email protected]> you…
If a
free()call is used on an already freed pointer we run into stability problems.
Is this actually the case anywhere in the code? If so, that code should be fixed, as thisis obviously a bug then.
I dislike workarounds like these as they just hush up design and/or implementation issues int he code. lease rather fix the real problems instead.
Thanks.
Quoted 1 line
Tested on i.MX27 Litekit board with eldk-2.0 toolchain.
ELDK 2.0? Wow. I did not think this was still in use anywhere around.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "Most people would like to be delivered from temptation but would like it to keep in touch." - Robert Orben
PATCH 2/2 mxc_fec: put freed pointers to NULL to avoid problems with further free() calls.
2009/10/19 Wolfgang Denk <[email protected]>:
Quoted 6 lines
Dear javier Martin,
Quoted 2 lines · In message <[email protected]> you…
If a
free()call is used on an already freed pointer we run into stability problems.
Quoted 8 lines
Is this actually the case anywhere in the code? If so, that code should be fixed, as thisis obviously a bug then.
I dislike workarounds like these as they just hush up design and/or implementation issues int he code. lease rather fix the real problems instead.
Thanks.
You are right.
Quoted 4 lines
Quoted 2 lines
Tested on i.MX27 Litekit board with eldk-2.0 toolchain.
ELDK 2.0? Wow. I did not think this was still in use anywhere around.
This is obviously a typo, I used eldk-4.2.
Quoted 11 lines
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "Most people would like to be delivered ?from ?temptation ?but ?would like it to keep in touch." ? ? ? ? ? ? ? ? ? ? ? ? ? ? - Robert Orben
Thank you for your comments, I will resent this patch fixing the real problem.
Signature · 7 lines
Javier Martin Vista Silicon S.L. CDTUC - FASE C - Oficina S-345 Avda de los Castros s/n 39005- Santander. Cantabria. Spain +34 942 25 32 60 www.vista-silicon.com