Skip to content

Commit

Permalink
V4L/DVB: media/radio: fix copy_to_user to user handling
Browse files Browse the repository at this point in the history
copy_to/from_user() returns the number of bytes remaining to be copied
but the code here was testing for negative returns.  I modified it to
return -EFAULT.  These functions are called from si4713_s_ext_ctrls() and
that only tests for negative error codes.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Dan Carpenter authored and Mauro Carvalho Chehab committed Aug 2, 2010
1 parent 398630e commit aac870a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/media/radio/si4713-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,10 @@ static int si4713_write_econtrol_string(struct si4713_device *sdev,
goto exit;
}
rval = copy_from_user(ps_name, control->string, len);
if (rval < 0)
if (rval) {
rval = -EFAULT;
goto exit;
}
ps_name[len] = '\0';

if (strlen(ps_name) % vqc.step) {
Expand All @@ -1031,8 +1033,10 @@ static int si4713_write_econtrol_string(struct si4713_device *sdev,
goto exit;
}
rval = copy_from_user(radio_text, control->string, len);
if (rval < 0)
if (rval) {
rval = -EFAULT;
goto exit;
}
radio_text[len] = '\0';

if (strlen(radio_text) % vqc.step) {
Expand Down Expand Up @@ -1367,6 +1371,8 @@ static int si4713_read_econtrol_string(struct si4713_device *sdev,
}
rval = copy_to_user(control->string, sdev->rds_info.ps_name,
strlen(sdev->rds_info.ps_name) + 1);
if (rval)
rval = -EFAULT;
break;

case V4L2_CID_RDS_TX_RADIO_TEXT:
Expand All @@ -1377,6 +1383,8 @@ static int si4713_read_econtrol_string(struct si4713_device *sdev,
}
rval = copy_to_user(control->string, sdev->rds_info.radio_text,
strlen(sdev->rds_info.radio_text) + 1);
if (rval)
rval = -EFAULT;
break;

default:
Expand Down

0 comments on commit aac870a

Please sign in to comment.