Re: [PATCH] drm/xe/query: Refactor copy_to_user() usage in four functions

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

 



>> Assign return values from copy_to_user() calls to additional local variables
>> so that four kfree() calls and return statements can be omitted accordingly.
…
>> +++ b/drivers/gpu/drm/xe/xe_query.c
>> @@ -220,13 +220,11 @@ static int query_engines(struct xe_device *xe,
>>
>>  	engines->num_engines = i;
>>
>> -	if (copy_to_user(query_ptr, engines, size)) {
>> +	{
>
> Please don't leave blocks like this behind when you remove the if.
…
>> +		unsigned long ctu = copy_to_user(query_ptr, engines, size);
>>  		kfree(engines);
>> -		return -EFAULT;
>> +		return ctu ? -EFAULT : 0;
>>  	}
>> -	kfree(engines);
>> -
>> -	return 0;
>>  }
…

Would you tolerate the shown variable definition without the proposed
compound statement?

Regards,
Markus





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux