public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Wang Yufen <wangyufen@huawei.com>
Cc: bvanassche@acm.org, jgg@ziepe.ca, leon@kernel.org,
	dennis.dalessandro@cornelisnetworks.com,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	bart.vanassche@wdc.com, easwar.hariharan@intel.com
Subject: Re: [PATCH 2/2] RDMA/srp: Fix error return code in srp_parse_options()
Date: Fri, 25 Nov 2022 16:37:37 +0200	[thread overview]
Message-ID: <Y4DTMQVenpsEiKHz@smile.fi.intel.com> (raw)
In-Reply-To: <1669377831-41386-2-git-send-email-wangyufen@huawei.com>

On Fri, Nov 25, 2022 at 08:03:51PM +0800, Wang Yufen wrote:
> In the previous while loop, "ret" may be assigned zero. Therefore,
> "ret" needs to be assigned -EINVAL at the beginning of each loop.

...

>  	while ((p = strsep(&sep_opt, ",\n")) != NULL) {
> +		ret = -EINVAL;
>  		if (!*p)
>  			continue;

Better option is to investigate each case separately and gather all of them
into a single fix.

For example, this

	case SRP_OPT_MAX_IT_IU_SIZE:
		if (match_int(args, &token) || token < 0) {
			pr_warn("bad maximum initiator to target IU size '%s'\n", p);
			goto out;
		}
		target->max_it_iu_size = token;
		break;

can be rewritten as

	case SRP_OPT_MAX_IT_IU_SIZE:
		ret = match_int(args, &token);
		if (ret)
			goto out;
		if (token < 0) {
			pr_warn("bad maximum initiator to target IU size '%s'\n", p);
			ret = -EINVAL;
			goto out;
		}
		target->max_it_iu_size = token;
		break;

and so on...

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2022-11-25 14:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-25 12:03 [PATCH 1/2] RDMA/hfi1: Fix error return code in parse_platform_config() Wang Yufen
2022-11-25 12:03 ` [PATCH 2/2] RDMA/srp: Fix error return code in srp_parse_options() Wang Yufen
2022-11-25 14:37   ` Andy Shevchenko [this message]
2022-11-26  1:23     ` wangyufen
2022-11-25 14:31 ` [PATCH 1/2] RDMA/hfi1: Fix error return code in parse_platform_config() Andy Shevchenko

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=Y4DTMQVenpsEiKHz@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bart.vanassche@wdc.com \
    --cc=bvanassche@acm.org \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=easwar.hariharan@intel.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=wangyufen@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox