Re: [PATCH] io_uring: fix xa_alloc_cycle() error return value check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux