Skip to content

Commit

Permalink
68328serial: check return value of copy_*_user() instead of access_ok()
Browse files Browse the repository at this point in the history
As copy_*_user() calls access_ok() it should not be called explicitly.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Kulikov Vasiliy authored and Greg Kroah-Hartman committed Aug 24, 2010
1 parent 80d04f2 commit 5d56356
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions drivers/serial/68328serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,9 @@ static int get_serial_info(struct m68k_serial * info,
tmp.close_delay = info->close_delay;
tmp.closing_wait = info->closing_wait;
tmp.custom_divisor = info->custom_divisor;
copy_to_user(retinfo,&tmp,sizeof(*retinfo));
if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
return -EFAULT;

return 0;
}

Expand All @@ -882,7 +884,8 @@ static int set_serial_info(struct m68k_serial * info,

if (!new_info)
return -EFAULT;
copy_from_user(&new_serial,new_info,sizeof(new_serial));
if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
return -EFAULT;
old_info = *info;

if (!capable(CAP_SYS_ADMIN)) {
Expand Down Expand Up @@ -943,8 +946,7 @@ static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
status = 0;
#endif
local_irq_restore(flags);
put_user(status,value);
return 0;
return put_user(status, value);
}

/*
Expand Down Expand Up @@ -999,27 +1001,18 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
send_break(info, arg ? arg*(100) : 250);
return 0;
case TIOCGSERIAL:
if (access_ok(VERIFY_WRITE, (void *) arg,
sizeof(struct serial_struct)))
return get_serial_info(info,
(struct serial_struct *) arg);
return -EFAULT;
return get_serial_info(info,
(struct serial_struct *) arg);
case TIOCSSERIAL:
return set_serial_info(info,
(struct serial_struct *) arg);
case TIOCSERGETLSR: /* Get line status register */
if (access_ok(VERIFY_WRITE, (void *) arg,
sizeof(unsigned int)))
return get_lsr_info(info, (unsigned int *) arg);
return -EFAULT;
return get_lsr_info(info, (unsigned int *) arg);
case TIOCSERGSTRUCT:
if (!access_ok(VERIFY_WRITE, (void *) arg,
sizeof(struct m68k_serial)))
if (copy_to_user((struct m68k_serial *) arg,
info, sizeof(struct m68k_serial)))
return -EFAULT;
copy_to_user((struct m68k_serial *) arg,
info, sizeof(struct m68k_serial));
return 0;

default:
return -ENOIOCTLCMD;
}
Expand Down

0 comments on commit 5d56356

Please sign in to comment.