[linux-next] KVM: x86: Replace IS_ERR() with IS_ERR_VALUE()

Message ID 20221020113943.400103-1-ye.xingchen@zte.com.cn
State New
Headers
Series [linux-next] KVM: x86: Replace IS_ERR() with IS_ERR_VALUE() |

Commit Message

ye xingchen Oct. 20, 2022, 11:39 a.m. UTC
  From: ye xingchen <ye.xingchen@zte.com.cn>

Avoid type casts that are needed for IS_ERR() and use
IS_ERR_VALUE() instead.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
 arch/x86/kvm/x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Sean Christopherson Oct. 20, 2022, 5:37 p.m. UTC | #1
On Thu, Oct 20, 2022, yexingchen116@gmail.com wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Avoid type casts that are needed for IS_ERR() and use
> IS_ERR_VALUE() instead.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---

Ignoring until things get sorted out.

https://lore.kernel.org/r/Y1EVnZS9BalesrC1@kroah.com
  
H. Peter Anvin Nov. 7, 2022, 5:30 p.m. UTC | #2
On 10/20/22 04:39, yexingchen116@gmail.com wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Avoid type casts that are needed for IS_ERR() and use
> IS_ERR_VALUE() instead.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
>   arch/x86/kvm/x86.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 4bd5f8a751de..1c260f716c3b 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -12414,7 +12414,7 @@ void __user * __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa,
>   		 */
>   		hva = vm_mmap(NULL, 0, size, PROT_READ | PROT_WRITE,
>   			      MAP_SHARED | MAP_ANONYMOUS, 0);
> -		if (IS_ERR((void *)hva))
> +		if (IS_ERR_VALUE(hva))
>   			return (void __user *)hva;
>   	} else {
>   		if (!slot || !slot->npages)

This seems to imply IS_ERR() is misdesigned.

It would be nice to have IS_ERR() contain the appropriate casts. If we 
want to enforce that the argument is a pointer, add IS_ERR_PTR()?

	-hpa
  

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4bd5f8a751de..1c260f716c3b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -12414,7 +12414,7 @@  void __user * __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa,
 		 */
 		hva = vm_mmap(NULL, 0, size, PROT_READ | PROT_WRITE,
 			      MAP_SHARED | MAP_ANONYMOUS, 0);
-		if (IS_ERR((void *)hva))
+		if (IS_ERR_VALUE(hva))
 			return (void __user *)hva;
 	} else {
 		if (!slot || !slot->npages)