From: Zhouyang Jia <jiazhouyang09@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Zhouyang Jia <jiazhouyang09@gmail.com>,
"Nicholas A. Bellinger" <nab@linux-iscsi.org>,
linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] target: add error handling for match_int
Date: Tue, 12 Jun 2018 12:52:28 +0800 [thread overview]
Message-ID: <1528779148-42485-1-git-send-email-jiazhouyang09@gmail.com> (raw)
When match_int fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling match_int.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
drivers/target/target_core_rd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
index a6e8106..7bc89ff 100644
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -573,14 +573,16 @@ static ssize_t rd_set_configfs_dev_params(struct se_device *dev,
token = match_token(ptr, tokens, args);
switch (token) {
case Opt_rd_pages:
- match_int(args, &arg);
+ if (match_int(args, &arg))
+ return -EINVAL;
rd_dev->rd_page_count = arg;
pr_debug("RAMDISK: Referencing Page"
" Count: %u\n", rd_dev->rd_page_count);
rd_dev->rd_flags |= RDF_HAS_PAGE_COUNT;
break;
case Opt_rd_nullio:
- match_int(args, &arg);
+ if (match_int(args, &arg))
+ return -EINVAL;
if (arg != 1)
break;
--
2.7.4
next reply other threads:[~2018-06-12 4:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 4:52 Zhouyang Jia [this message]
2018-06-12 13:25 ` [PATCH] target: add error handling for match_int Bart Van Assche
2018-06-12 21:21 ` James Bottomley
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=1528779148-42485-1-git-send-email-jiazhouyang09@gmail.com \
--to=jiazhouyang09@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=target-devel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox