Thread (13 messages) 13 messages, 1 author, 2011-08-25
STALE5440d

[RFC PATCH 03/12] wl128x: fix compiler warning + wrong write() return.

From: Hans Verkuil <hidden>
Date: 2011-08-25 14:08:47
Subsystem: media input infrastructure (v4l/dvb), the rest · Maintainers: Mauro Carvalho Chehab, Linus Torvalds

From: Hans Verkuil <redacted>

v4l-dvb-git/drivers/media/radio/wl128x/fmdrv_v4l2.c: In function 'fm_v4l2_fops_write':
v4l-dvb-git/drivers/media/radio/wl128x/fmdrv_v4l2.c:81:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]

The fix is to check for ret and return -EFAULT if non-zero.

I also noticed that write() didn't return the number of bytes written.
Fixed as well.

Signed-off-by: Hans Verkuil <redacted>
---
 drivers/media/radio/wl128x/fmdrv_v4l2.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c
index 8c0e192..478d1e9 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.c
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -84,12 +84,14 @@ static ssize_t fm_v4l2_fops_write(struct file *file, const char __user * buf,
 	ret = copy_from_user(&rds, buf, sizeof(rds));
 	fmdbg("(%d)type: %d, text %s, af %d\n",
 		   ret, rds.text_type, rds.text, rds.af_freq);
+	if (ret)
+		return -EFAULT;
 
 	fmdev = video_drvdata(file);
 	fm_tx_set_radio_text(fmdev, rds.text, rds.text_type);
 	fm_tx_set_af(fmdev, rds.af_freq);
 
-	return 0;
+	return sizeof(rds);
 }
 
 static u32 fm_v4l2_fops_poll(struct file *file, struct poll_table_struct *pts)
-- 
1.7.5.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help