Patchwork [v2,1/1] booke/wdt: some ioctls do not return values properly

login
register
mail settings
Submitter Tiejun Chen
Date Aug. 7, 2012, 1:59 a.m.
Message ID <1344304780-13555-1-git-send-email-tiejun.chen@windriver.com>
Download mbox | patch
Permalink /patch/175493/
State Accepted, archived
Commit 127c6e731106a2071ee4a6c5a34c471cd3e719f0
Headers show

Comments

Tiejun Chen - Aug. 7, 2012, 1:59 a.m.
Fix some booke wdt ioctls return value error.

Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
---
 drivers/watchdog/booke_wdt.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
Tabi Timur-B04825 - Aug. 7, 2012, 2:20 a.m.
On Mon, Aug 6, 2012 at 8:59 PM, Tiejun Chen <tiejun.chen@windriver.com> wrote:
> Fix some booke wdt ioctls return value error.
>
> Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>

It's not the greatest patch description, but it'll do.

Acked-by: Timur Tabi <timur@freescale.com>
Kumar Gala - Aug. 17, 2012, 2:07 p.m.
On Aug 6, 2012, at 8:59 PM, Tiejun Chen wrote:

> Fix some booke wdt ioctls return value error.
> 
> Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
> ---
> drivers/watchdog/booke_wdt.c |    7 +++----
> 1 files changed, 3 insertions(+), 4 deletions(-)

applied to merge

- k

Patch

diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
index 3fe82d0..5b06d31 100644
--- a/drivers/watchdog/booke_wdt.c
+++ b/drivers/watchdog/booke_wdt.c
@@ -166,18 +166,17 @@  static long booke_wdt_ioctl(struct file *file,
 
 	switch (cmd) {
 	case WDIOC_GETSUPPORT:
-		if (copy_to_user((void *)arg, &ident, sizeof(ident)))
-			return -EFAULT;
+		return copy_to_user(p, &ident, sizeof(ident)) ? -EFAULT : 0;
 	case WDIOC_GETSTATUS:
 		return put_user(0, p);
 	case WDIOC_GETBOOTSTATUS:
 		/* XXX: something is clearing TSR */
 		tmp = mfspr(SPRN_TSR) & TSR_WRS(3);
 		/* returns CARDRESET if last reset was caused by the WDT */
-		return (tmp ? WDIOF_CARDRESET : 0);
+		return put_user((tmp ? WDIOF_CARDRESET : 0), p);
 	case WDIOC_SETOPTIONS:
 		if (get_user(tmp, p))
-			return -EINVAL;
+			return -EFAULT;
 		if (tmp == WDIOS_ENABLECARD) {
 			booke_wdt_ping();
 			break;