* slram.c modifications
@ 2001-04-26 9:49 Jochen Schaeuble
0 siblings, 0 replies; only message in thread
From: Jochen Schaeuble @ 2001-04-26 9:49 UTC (permalink / raw)
To: mtd
[-- Attachment #1: Type: text/plain, Size: 531 bytes --]
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
[-- Attachment #2: slram.patch --]
[-- Type: text/plain, Size: 644 bytes --]
Index: slram.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/slram.c,v
retrieving revision 1.14
diff -u -r1.14 slram.c
--- slram.c 2001/01/11 15:17:42 1.14
+++ slram.c 2001/04/26 09:38:41
@@ -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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-04-26 9:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-26 9:49 slram.c modifications Jochen Schaeuble
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox