Skip to content

Commit

Permalink
HID: wiimote: fix DRM debug-attr to correctly parse input
Browse files Browse the repository at this point in the history
We need to correctly zero-terminate the input to parse it. Otherwise, we
always end up interpreting it as numbers.
Furthermore, we actually want hexadecimal numbers instead of decimal. As
it is a debugfs interface, we can change the API at any time.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
David Herrmann authored and Jiri Kosina committed Jun 3, 2013
1 parent 9f32974 commit 0d57eb8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/hid/hid-wiimote-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static ssize_t wiidebug_drm_write(struct file *f, const char __user *u,
if (copy_from_user(buf, u, len))
return -EFAULT;

buf[15] = 0;
buf[len] = 0;

for (i = 0; i < WIIPROTO_REQ_MAX; ++i) {
if (!wiidebug_drmmap[i])
Expand All @@ -151,7 +151,7 @@ static ssize_t wiidebug_drm_write(struct file *f, const char __user *u,
}

if (i == WIIPROTO_REQ_MAX)
i = simple_strtoul(buf, NULL, 10);
i = simple_strtoul(buf, NULL, 16);

spin_lock_irqsave(&dbg->wdata->state.lock, flags);
dbg->wdata->state.flags &= ~WIIPROTO_FLAG_DRM_LOCKED;
Expand Down

0 comments on commit 0d57eb8

Please sign in to comment.