public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Shaohua Li <shaohua.li@intel.com>
To: Lukas Czerner <lczerner@redhat.com>
Cc: Eric Sandeen <sandeen@redhat.com>,
	"linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>,
	Ted Ts'o <tytso@mit.edu>
Subject: Re: [patch]check NULL pointer
Date: Mon, 13 Jun 2011 15:30:58 +0800	[thread overview]
Message-ID: <1307950258.15392.113.camel@sli10-conroe> (raw)
In-Reply-To: <alpine.LFD.2.00.1106101029160.4502@dhcp-27-109.brq.redhat.com>

On Fri, 2011-06-10 at 16:32 +0800, Lukas Czerner wrote:
> On Fri, 10 Jun 2011, Shaohua Li wrote:
> 
> > On Thu, 2011-06-09 at 22:51 +0800, Eric Sandeen wrote:
> > > On 6/9/11 4:24 AM, Lukas Czerner wrote:
> > > > On Thu, 9 Jun 2011, Shaohua Li wrote:
> > > > 
> > > >> orig_data could be NULL.
> > > > 
> > > > Now, that is the commit description :). Could you please be more
> > > > descriptive in the "descritpion" ? Also the subject is not right either,
> > > > please see Documentation/SubmittingPatches
> > > 
> > > Yes; if possible please use the commit message to describe how/why orig_data
> > > can be NULL; a testcase if one exists; the resulting flaw (null pointer deref?)
> > > etc.
> > > 
> > > something like:
> > > 
> > > Subject: [PATCH] ext4: check for NULL orig_data pointer in mount paths
> > > 
> > > The orig_data pointer in ext4_fill_super()  and ext4_remount()
> > > can be null if < ??? >, which can lead to < ??? > in the mount
> > > and remount paths.  This can be demonstrated by < ??? >.  
> > > To avoid this, we can simply test for the null pointer
> > > and return an error in ext4_fill_super() and ext4_remount().
> > I thought the reason is pretty straightforward, anyway here is the
> > updated patch.
> > 
> > Subject: [patch]ext4: check NULL pointer for mount and remount
> > 
> > orig_data could be NULL, because the memory allocation of kstrdup() could fail.
> > Add the NULL check.
> 
> I am sorry, but as I pointed out in previous mail this is not true.
> *orig_data can be also NULL in the case that *data is NULL and hence
> there is no reason for exiting with error. Also please use the subject
> Eric suggested.
Hmm, maybe we just don't use the pointer if it's NULl. it's just print
info anyway.

Subject: [patch]ext4: check NULL orig_data pointer for mount and remount

orig_data could be NULL, because the memory allocation of kstrdup()
could fail or data is NULL. Add the NULL check.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index cc5c157..68eba3b 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3706,7 +3706,7 @@ no_journal:
 
 	ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. "
 		 "Opts: %s%s%s", descr, sbi->s_es->s_mount_opts,
-		 *sbi->s_es->s_mount_opts ? "; " : "", orig_data);
+		 *sbi->s_es->s_mount_opts ? "; " : "", orig_data ? : ";");
 
 	if (es->s_error_count)
 		mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */
@@ -4443,7 +4443,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
 	if (enable_quota)
 		dquot_resume(sb, -1);
 
-	ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s", orig_data);
+	ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s", orig_data ? : ";");
 	kfree(orig_data);
 	return 0;
 



  reply	other threads:[~2011-06-13  7:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-09  3:31 [patch]check NULL pointer Shaohua Li
2011-06-09  9:24 ` Lukas Czerner
2011-06-09 14:51   ` Eric Sandeen
2011-06-10  6:34     ` Shaohua Li
2011-06-10  8:32       ` Lukas Czerner
2011-06-13  7:30         ` Shaohua Li [this message]
2011-06-13  9:20           ` Lukas Czerner
2011-06-13 21:02             ` Ted Ts'o
2011-06-14  0:31             ` Shaohua Li
2011-06-14 10:07               ` Lukas Czerner

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=1307950258.15392.113.camel@sli10-conroe \
    --to=shaohua.li@intel.com \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=tytso@mit.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox