slram.c modifications
After reading the slram sources I found two things. First of all the
memset(mymtd, 0, sizeof(*mymtd));
In my opinion this is not neccesary because this is done two lines below this one. The next thing I found is the
memset(mymtd->priv, 0, sizeof(struct mypriv));
If the allocation of the priv field failed above mymtd is set to NULL. If the priv-field is accessed I guess this would lead to a segmentation fault.
Attached to this mail I send a patch to cover both this issues. I hope this may be helpfull in some way.
jochen
Index: slram.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/slram.c,v retrieving revision 1.14
slram.c +2 -3
@@ -156,8 +156,6 @@ mymtd =kmalloc (sizeof (struct mtd_info ),GFP_KERNEL ); -memset (mymtd,0 ,sizeof (*mymtd)); -if (mymtd) {memset ((char *)mymtd,0 ,sizeof (struct mtd_info ));
@@ -166,8 +164,9 @@ {kfree (mymtd); mymtd =NULL ; + } else { +memset (mymtd->priv,0 ,sizeof (struct mypriv )); } -memset (mymtd->priv,0 ,sizeof (struct mypriv )); }if (!mymtd)