ath9k/debug: fixup the return codes
PATCH 2/2 ath9k/debug: fixup the return codes
Changed -EINVAL to -EFAULT if copy_to_user() failed. Changed 0 to -ENOMEM if allocations failed.
Signed-off-by Dan Carpenter <[email protected]>
drivers/net/wireless/ath/ath9k/debug.c +9 -9
@@ -56,7 +56,7 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf, len =min (count,sizeof (buf) -1 );if (copy_from_user (buf, user_buf, len)) -return -EINVAL ; +return -EFAULT ; buf[len] ='\0' ;if (strict_strtoul (buf,0 , &mask))
@@ -100,7 +100,7 @@ static ssize_t write_file_tx_chainmask(struct file *file, const char __user *use len =min (count,sizeof (buf) -1 );if (copy_from_user (buf, user_buf, len)) -return -EINVAL ; +return -EFAULT ; buf[len] ='\0' ;if (strict_strtoul (buf,0 , &mask))
@@ -142,7 +142,7 @@ static ssize_t write_file_rx_chainmask(struct file *file, const char __user *use len =min (count,sizeof (buf) -1 );if (copy_from_user (buf, user_buf, len)) -return -EINVAL ; +return -EFAULT ; buf[len] ='\0' ;if (strict_strtoul (buf,0 , &mask))
@@ -175,7 +175,7 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf, buf =kmalloc (DMA_BUF_LEN ,GFP_KERNEL );if (!buf) -return 0 ; +return -ENOMEM ;ath9k_ps_wakeup (sc);
@@ -405,7 +405,7 @@ static ssize_t read_file_rcstat(struct file *file, char __user *user_buf, max =80 + sc->cur_rate_table->rate_cnt *1024 +1 ; buf =kmalloc (max,GFP_KERNEL );if (buf ==NULL ) -return 0 ; +return -ENOMEM ; len += sprintf(buf, "%6s %6s %6s " "%10s %10s %10s %10s\n",
@@ -640,7 +640,7 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf, buf =kzalloc (size,GFP_KERNEL );if (buf ==NULL ) -return 0 ; +return -ENOMEM ; len +=sprintf (buf,"%30s %10s%10s%10s\n\n" ,"BE" ,"BK" ,"VI" ,"VO" );
@@ -713,7 +713,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf, buf =kzalloc (size,GFP_KERNEL );if (buf ==NULL ) -return 0 ; +return -ENOMEM ; len += snprintf(buf + len, size - len, "%18s : %10u\n", "CRC ERR",
@@ -832,7 +832,7 @@ static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, len =min (count,sizeof (buf) -1 );if (copy_from_user (buf, user_buf, len)) -return -EINVAL ; +return -EFAULT ; buf[len] ='\0' ;if (strict_strtoul (buf,0 , ®idx))
@@ -874,7 +874,7 @@ static ssize_t write_file_regval(struct file *file, const char __user *user_buf, len =min (count,sizeof (buf) -1 );if (copy_from_user (buf, user_buf, len)) -return -EINVAL ; +return -EFAULT ; buf[len] ='\0' ;if (strict_strtoul (buf,0 , ®val))
PATCH v2 2/2 ath9k/debug: fixup the return codes
Changed -EINVAL to -EFAULT if copy_to_user() failed. Changed 0 to -ENOMEM if allocations failed.
Signed-off-by Dan Carpenter <[email protected]>
---
V2: No change. Just updated to apply on top of V2 of the earlier patch
drivers/net/wireless/ath/ath9k/debug.c +9 -9
@@ -56,7 +56,7 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf, len =min (count,sizeof (buf) -1 );if (copy_from_user (buf, user_buf, len)) -return -EINVAL ; +return -EFAULT ; buf[len] ='\0' ;if (strict_strtoul (buf,0 , &mask))
@@ -100,7 +100,7 @@ static ssize_t write_file_tx_chainmask(struct file *file, const char __user *use len =min (count,sizeof (buf) -1 );if (copy_from_user (buf, user_buf, len)) -return -EINVAL ; +return -EFAULT ; buf[len] ='\0' ;if (strict_strtoul (buf,0 , &mask))
@@ -142,7 +142,7 @@ static ssize_t write_file_rx_chainmask(struct file *file, const char __user *use len =min (count,sizeof (buf) -1 );if (copy_from_user (buf, user_buf, len)) -return -EINVAL ; +return -EFAULT ; buf[len] ='\0' ;if (strict_strtoul (buf,0 , &mask))
@@ -175,7 +175,7 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf, buf =kmalloc (DMA_BUF_LEN ,GFP_KERNEL );if (!buf) -return 0 ; +return -ENOMEM ;ath9k_ps_wakeup (sc);
@@ -407,7 +407,7 @@ static ssize_t read_file_rcstat(struct file *file, char __user *user_buf, max =80 + sc->cur_rate_table->rate_cnt *1024 +1 ; buf =kmalloc (max,GFP_KERNEL );if (buf ==NULL ) -return 0 ; +return -ENOMEM ; len += sprintf(buf, "%6s %6s %6s " "%10s %10s %10s %10s\n",
@@ -644,7 +644,7 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf, buf =kzalloc (size,GFP_KERNEL );if (buf ==NULL ) -return 0 ; +return -ENOMEM ; len +=sprintf (buf,"%30s %10s%10s%10s\n\n" ,"BE" ,"BK" ,"VI" ,"VO" );
@@ -718,7 +718,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf, buf =kzalloc (size,GFP_KERNEL );if (buf ==NULL ) -return 0 ; +return -ENOMEM ; len += snprintf(buf + len, size - len, "%18s : %10u\n", "CRC ERR",
@@ -838,7 +838,7 @@ static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, len =min (count,sizeof (buf) -1 );if (copy_from_user (buf, user_buf, len)) -return -EINVAL ; +return -EFAULT ; buf[len] ='\0' ;if (strict_strtoul (buf,0 , ®idx))
@@ -880,7 +880,7 @@ static ssize_t write_file_regval(struct file *file, const char __user *user_buf, len =min (count,sizeof (buf) -1 );if (copy_from_user (buf, user_buf, len)) -return -EINVAL ; +return -EFAULT ; buf[len] ='\0' ;if (strict_strtoul (buf,0 , ®val))