[PATCH] lightnvm: Return the correct return value

Subsystems: the rest

STALE1938d

2 messages, 2 authors, 2021-04-13 · open the first message on its own page

[PATCH] lightnvm: Return the correct return value

From: Tian Tao <tiantao6@hisilicon.com>
Date: 2021-04-12 07:38:43

When memdup_user returns an error, memdup_user has two different return
values, use PTR_ERR to get the correct return value.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
---
 drivers/lightnvm/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 28ddcaa..42774be 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -1257,7 +1257,7 @@ static long nvm_ioctl_info(struct file *file, void __user *arg)
 
 	info = memdup_user(arg, sizeof(struct nvm_ioctl_info));
 	if (IS_ERR(info))
-		return -EFAULT;
+		return PTR_ERR(info);
 
 	info->version[0] = NVM_VERSION_MAJOR;
 	info->version[1] = NVM_VERSION_MINOR;
-- 
2.7.4

Re: [PATCH] lightnvm: Return the correct return value

From: Matias Bjørling <hidden>
Date: 2021-04-13 10:54:25

On 12/04/2021 09.38, Tian Tao wrote:
quoted hunk
When memdup_user returns an error, memdup_user has two different return
values, use PTR_ERR to get the correct return value.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
---
  drivers/lightnvm/core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 28ddcaa..42774be 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -1257,7 +1257,7 @@ static long nvm_ioctl_info(struct file *file, void __user *arg)
  
  	info = memdup_user(arg, sizeof(struct nvm_ioctl_info));
  	if (IS_ERR(info))
-		return -EFAULT;
+		return PTR_ERR(info);
  
  	info->version[0] = NVM_VERSION_MAJOR;
  	info->version[1] = NVM_VERSION_MINOR;
Thanks, Tian. It has been pulled.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help