From: David Disseldorp <ddiss@suse.de>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, christophe.jaillet@wanadoo.fr,
andriy.shevchenko@linux.intel.com, David.Laight@ACULAB.COM
Subject: Re: [PATCH 3/3] btrfs: migrate to the newer memparse_safe() helper
Date: Wed, 27 Dec 2023 17:27:09 +1100 [thread overview]
Message-ID: <20231227172709.4402bc6c@echidna> (raw)
In-Reply-To: <6dfa53ded887caa2269c1beeaedcff086342339a.1703324146.git.wqu@suse.com>
On Sat, 23 Dec 2023 20:28:07 +1030, Qu Wenruo wrote:
> The new helper has better error report and correct overflow detection,
> furthermore the old @retptr behavior is also kept, thus there should be
> no behavior change.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> fs/btrfs/ioctl.c | 8 ++++++--
> fs/btrfs/super.c | 8 ++++++++
> fs/btrfs/sysfs.c | 14 +++++++++++---
> 3 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 4e50b62db2a8..8bfd4b4ccf02 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -1175,8 +1175,12 @@ static noinline int btrfs_ioctl_resize(struct file *file,
> mod = 1;
> sizestr++;
> }
> - new_size = memparse(sizestr, &retptr);
> - if (*retptr != '\0' || new_size == 0) {
> +
> + ret = memparse_safe(sizestr, MEMPARSE_SUFFIXES_DEFAULT,
> + &new_size, &retptr);
> + if (ret < 0)
> + goto out_finish;
> + if (*retptr != '\0') {
Was dropping the -EINVAL return for new_size=0 intentional?
> ret = -EINVAL;
> goto out_finish;
> }
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 3a677b808f0f..2bb6ea525e89 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -400,6 +400,14 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
> ctx->thread_pool_size = result.uint_32;
> break;
> case Opt_max_inline:
> + int ret;
> +
> + ret = memparse_safe(param->string, MEMPARSE_SUFFIXES_DEFAULT,
> + &ctx->max_inline, NULL);
> + if (ret < 0) {
> + btrfs_err(NULL, "invalid string \"%s\"", param->string);
> + return ret;
> + }
> ctx->max_inline = memparse(param->string, NULL);
Looks like you overlooked removal of the old memparse() call above.
Cheers, David
next prev parent reply other threads:[~2023-12-27 6:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-23 9:58 [PATCH 0/3] kstrtox: introduce memparse_safe() Qu Wenruo
2023-12-23 9:58 ` [PATCH 1/3] kstrtox: introduce a safer version of memparse() Qu Wenruo
2023-12-27 13:26 ` David Disseldorp
2023-12-27 20:29 ` Qu Wenruo
2023-12-23 9:58 ` [PATCH 2/3] kstrtox: add unit tests for memparse_safe() Qu Wenruo
2023-12-26 6:36 ` kernel test robot
2023-12-26 7:37 ` Qu Wenruo
2024-01-02 1:33 ` Yujie Liu
2024-01-02 2:03 ` Qu Wenruo
2023-12-23 9:58 ` [PATCH 3/3] btrfs: migrate to the newer memparse_safe() helper Qu Wenruo
2023-12-26 4:53 ` kernel test robot
2023-12-26 6:06 ` kernel test robot
2023-12-27 6:27 ` David Disseldorp [this message]
2023-12-27 8:26 ` Qu Wenruo
2023-12-27 16:12 ` [PATCH 0/3] kstrtox: introduce memparse_safe() Andy Shevchenko
-- strict thread matches above, loose matches on Subject: below --
2023-12-26 1:24 [PATCH 3/3] btrfs: migrate to the newer memparse_safe() helper kernel test robot
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=20231227172709.4402bc6c@echidna \
--to=ddiss@suse.de \
--cc=David.Laight@ACULAB.COM \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wqu@suse.com \
/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.