All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Matthew Wilcox <willy@infradead.org>
Cc: io-uring <io-uring@vger.kernel.org>
Subject: Re: [PATCH] io_uring: fix xa_alloc_cycle() error return value check
Date: Fri, 20 Aug 2021 16:05:23 -0600	[thread overview]
Message-ID: <9e660f69-0adb-2738-6bb1-79e9d0d4e8a0@kernel.dk> (raw)
In-Reply-To: <YSAjeuZ0zqJOkwUm@casper.infradead.org>

On 8/20/21 3:49 PM, Matthew Wilcox wrote:
> On Fri, Aug 20, 2021 at 03:01:20PM -0600, Jens Axboe wrote:
>>  	ret = xa_alloc_cyclic(&ctx->personalities, &id, (void *)creds,
>>  			XA_LIMIT(0, USHRT_MAX), &ctx->pers_next, GFP_KERNEL);
>> -	if (!ret)
>> -		return id;
>> -	put_cred(creds);
>> -	return ret;
>> +	if (ret < 0) {
>> +		put_cred(creds);
>> +		return ret;
>> +	}
>> +	return id;
>>  }
> 
> Wouldn't you rather:
> 
> 	if (ret >= 0)
> 		return id;
> 	put_cred(creds);
> 	return ret;

Don't really feel that strongly, I tend to like to do the error path
like that unless it's a hot path. But I can go either way, if someone
else feels strongly about it :-)

-- 
Jens Axboe


      reply	other threads:[~2021-08-20 22:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20 20:57 [PATCH] io_uring: fix xa_alloc_cycle() error return value check Jens Axboe
2021-08-20 21:01 ` Jens Axboe
2021-08-20 21:49   ` Matthew Wilcox
2021-08-20 22:05     ` Jens Axboe [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=9e660f69-0adb-2738-6bb1-79e9d0d4e8a0@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=willy@infradead.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 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.