All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jochen Schaeuble <psionic@psionic.de>
To: mtd@infradead.org
Subject: slram.c modifications
Date: Thu, 26 Apr 2001 11:49:20 +0200	[thread overview]
Message-ID: <20010426114920.B1198@psionic.de> (raw)

[-- 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)

                 reply	other threads:[~2001-04-26  9:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010426114920.B1198@psionic.de \
    --to=psionic@psionic.de \
    --cc=mtd@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.