From: Dave Chinner <david@fromorbit.com>
To: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Cc: Christoph Hellwig <hch@infradead.org>, Ben Myers <bpm@sgi.com>,
Zach Brown <zab@zabbo.net>,
xfs@oss.sgi.com
Subject: Re: [PATCH V5] xfs: cleanup the mount options
Date: Tue, 24 Jul 2012 09:28:13 +1000 [thread overview]
Message-ID: <20120723232813.GL23387@dastard> (raw)
In-Reply-To: <1341988145-12994-1-git-send-email-gaowanlong@cn.fujitsu.com>
On Wed, Jul 11, 2012 at 02:29:05PM +0800, Wanlong Gao wrote:
> - return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
> + string = match_strdup(s);
GFP_KERNEL allocation....
> + if (!string)
> + return ENOMEM;
> +
> + *result = simple_strtoul((const char *)string, NULL, 0) <<
> + shift_left_factor;
> +
> + kfree(string);
> + return 0;
> +}
> +
> +STATIC int
> +match_name_strdup(substring_t *s, char *name)
> +{
> + char *string;
> + string = match_strdup(s);
GFP_KERNEL allocation....
> + if (!string)
> + return ENOMEM;
> +
> + name = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
GFP_KERNEL allocation....
> + if (!name)
> + goto free;
> + return 0;
Leaks string - it should always be freed.
> +free:
> + kfree(string);
> + return ENOMEM;
> }
>
> /*
> @@ -166,11 +246,15 @@ xfs_parseargs(
> char *options)
> {
> struct super_block *sb = mp->m_super;
> - char *this_char, *value, *eov;
> + char *p;
> int dsunit = 0;
> int dswidth = 0;
> - int iosize = 0;
> __uint8_t iosizelog = 0;
> + int intarg;
> + unsigned long ularg;
> + substring_t args[MAX_OPT_ARGS];
> + char *orig = NULL;
> + int ret = 0;
>
> /*
> * set up the mount name first so all the errors will refer to the
> @@ -208,175 +292,192 @@ xfs_parseargs(
> if (!options)
> goto done;
>
> - while ((this_char = strsep(&options, ",")) != NULL) {
> - if (!*this_char)
> + options = kstrdup(options, GFP_NOFS);
GFP_NOFS allocation. Why is this GFP_NOFS, and all the other
allocations GFP_KERNEL? If it is not safe to use GFP_KERNEL
allocations here, then all of the above allocations need to be
GFP_NOFS, too.
> + if (!options) {
> + ret = ENOMEM;
> + goto done;
> + }
> +
> + orig = options;
Also, no need to set up orig like this. Just a simple:
orig = kstrdup(options, GFP_NOFS);
if (!orig) {
ret = ENOMEM;
goto done;
}
will work fine.
....
> if (mp->m_logbufs > 0)
> - seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
> + seq_printf(seq, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
> if (mp->m_logbsize > 0)
> - seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
> + seq_printf(seq, "," MNTOPT_LOGBSIZE "=%dk",
> + mp->m_logbsize >> 10);
Change of user visible output format here. That will break any
scripts that are parsing the output and expecting numbers. Just
leave it as a raw number.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-07-23 23:34 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-27 16:57 [PATCH] xfs: cleanup the mount options Wanlong Gao
2012-06-27 17:44 ` Christoph Hellwig
2012-06-28 0:54 ` Wanlong Gao
2012-06-28 16:01 ` Ben Myers
2012-06-28 16:33 ` Zach Brown
2012-06-28 19:54 ` Carlos Maiolino
2012-06-29 1:00 ` Wanlong Gao
2012-06-29 16:29 ` Zach Brown
2012-06-29 16:37 ` Wanlong Gao
2012-06-29 18:06 ` [PATCH 1/2 V2] " Wanlong Gao
2012-06-29 18:06 ` [PATCH 2/2] xfs: rename xfs_fs_* to xfs_* Wanlong Gao
2012-07-01 23:47 ` Dave Chinner
2012-07-02 0:39 ` Wanlong Gao
2012-07-02 6:26 ` [PATCH 1/2 V2] xfs: cleanup the mount options Christoph Hellwig
2012-07-02 7:05 ` [PATCH V3] " Wanlong Gao
2012-07-06 3:05 ` Dave Chinner
2012-07-08 11:36 ` [PATCH V4] " Wanlong Gao
2012-07-09 0:22 ` Dave Chinner
2012-07-09 9:21 ` Wanlong Gao
2012-07-11 2:26 ` Dave Chinner
2012-07-11 6:29 ` [PATCH V5] " Wanlong Gao
2012-07-16 8:06 ` Wanlong Gao
2012-07-23 20:33 ` Ben Myers
2012-07-23 23:28 ` Dave Chinner [this message]
2012-07-24 2:01 ` Wanlong Gao
2012-07-24 21:18 ` Dave Chinner
2012-07-25 1:09 ` Wanlong Gao
2012-07-25 1:11 ` [PATCH V7] " Wanlong Gao
2012-07-29 22:09 ` Dave Chinner
2012-08-28 19:38 ` Ben Myers
2012-07-24 2:10 ` [PATCH V6] " Wanlong Gao
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=20120723232813.GL23387@dastard \
--to=david@fromorbit.com \
--cc=bpm@sgi.com \
--cc=gaowanlong@cn.fujitsu.com \
--cc=hch@infradead.org \
--cc=xfs@oss.sgi.com \
--cc=zab@zabbo.net \
/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