aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/si4713-i2c.c
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2010-06-04 06:34:40 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-08-02 14:28:51 -0400
commitaac870a8770281c6ad619b538df77840b9513a0b (patch)
tree65c7b64f8c7200c64411e8eced9bfddd1e6f3751 /drivers/media/radio/si4713-i2c.c
parent398630e4edadac3d21519b8d009e30c3cdd91926 (diff)
V4L/DVB: media/radio: fix copy_to_user to user handling
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>
Diffstat (limited to 'drivers/media/radio/si4713-i2c.c')
-rw-r--r--drivers/media/radio/si4713-i2c.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/media/radio/si4713-i2c.c b/drivers/media/radio/si4713-i2c.c
index ab63dd5b25c4..fc7f4b794649 100644
--- a/drivers/media/radio/si4713-i2c.c
+++ b/drivers/media/radio/si4713-i2c.c
@@ -1009,8 +1009,10 @@ static int si4713_write_econtrol_string(struct si4713_device *sdev,
1009 goto exit; 1009 goto exit;
1010 } 1010 }
1011 rval = copy_from_user(ps_name, control->string, len); 1011 rval = copy_from_user(ps_name, control->string, len);
1012 if (rval < 0) 1012 if (rval) {
1013 rval = -EFAULT;
1013 goto exit; 1014 goto exit;
1015 }
1014 ps_name[len] = '\0'; 1016 ps_name[len] = '\0';
1015 1017
1016 if (strlen(ps_name) % vqc.step) { 1018 if (strlen(ps_name) % vqc.step) {
@@ -1031,8 +1033,10 @@ static int si4713_write_econtrol_string(struct si4713_device *sdev,
1031 goto exit; 1033 goto exit;
1032 } 1034 }
1033 rval = copy_from_user(radio_text, control->string, len); 1035 rval = copy_from_user(radio_text, control->string, len);
1034 if (rval < 0) 1036 if (rval) {
1037 rval = -EFAULT;
1035 goto exit; 1038 goto exit;
1039 }
1036 radio_text[len] = '\0'; 1040 radio_text[len] = '\0';
1037 1041
1038 if (strlen(radio_text) % vqc.step) { 1042 if (strlen(radio_text) % vqc.step) {
@@ -1367,6 +1371,8 @@ static int si4713_read_econtrol_string(struct si4713_device *sdev,
1367 } 1371 }
1368 rval = copy_to_user(control->string, sdev->rds_info.ps_name, 1372 rval = copy_to_user(control->string, sdev->rds_info.ps_name,
1369 strlen(sdev->rds_info.ps_name) + 1); 1373 strlen(sdev->rds_info.ps_name) + 1);
1374 if (rval)
1375 rval = -EFAULT;
1370 break; 1376 break;
1371 1377
1372 case V4L2_CID_RDS_TX_RADIO_TEXT: 1378 case V4L2_CID_RDS_TX_RADIO_TEXT:
@@ -1377,6 +1383,8 @@ static int si4713_read_econtrol_string(struct si4713_device *sdev,
1377 } 1383 }
1378 rval = copy_to_user(control->string, sdev->rds_info.radio_text, 1384 rval = copy_to_user(control->string, sdev->rds_info.radio_text,
1379 strlen(sdev->rds_info.radio_text) + 1); 1385 strlen(sdev->rds_info.radio_text) + 1);
1386 if (rval)
1387 rval = -EFAULT;
1380 break; 1388 break;
1381 1389
1382 default: 1390 default: