mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Christie <mchristi@redhat.com>
To: Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu, "Nicholas A. Bellinger" <nab@linux-iscsi.org>,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] target: fix a missing check of match_int
Date: Sat, 19 Jan 2019 13:06:31 -0600	[thread overview]
Message-ID: <5C437537.8010304@redhat.com> (raw)
In-Reply-To: <20190112053159.99406-1-kjlu@umn.edu>

On 01/11/2019 11:31 PM, Kangjie Lu wrote:
> When match_int fails, "arg" is left uninitialized and may contain random
> value, thus should not be used.
> The fix checks if match_int fails, and if so, returns its error code.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>  drivers/target/target_core_rd.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
> index a6e8106abd6f..3b7657b2f2f1 100644
> --- a/drivers/target/target_core_rd.c
> +++ b/drivers/target/target_core_rd.c
> @@ -559,6 +559,7 @@ static ssize_t rd_set_configfs_dev_params(struct se_device *dev,
>  	char *orig, *ptr, *opts;
>  	substring_t args[MAX_OPT_ARGS];
>  	int arg, token;
> +	int ret;
>  
>  	opts = kstrdup(page, GFP_KERNEL);
>  	if (!opts)
> @@ -573,14 +574,24 @@ 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);
> +			ret = match_int(args, &arg);
> +			if (ret) {
> +				kfree(orig);
> +				return ret;

Just set ret to the return value and then break, so all the error and
success paths are going through the same code path.

      reply	other threads:[~2019-01-19 19:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-26  6:48 [PATCH] target: fix a missing check for match_int Kangjie Lu
2019-01-11 20:06 ` Mike Christie
2019-01-12  5:31   ` [PATCH v2] target: fix a missing check of match_int Kangjie Lu
2019-01-19 19:06     ` Mike Christie [this message]

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=5C437537.8010304@redhat.com \
    --to=mchristi@redhat.com \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=pakki001@umn.edu \
    --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

Powered by JetHome