aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/i4l
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-10-17 03:10:39 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-17 11:18:49 -0400
commit04518bfe8eac2e82b476fb2b0093527adc2bc791 (patch)
tree4b90b18cb60d1db94325675886b74f0aa0bf346f /drivers/isdn/i4l
parent078d396598401dbaa88d5f95ec45579f9d3dce0e (diff)
[PATCH] ISDN: fix drivers, by handling errors thrown by ->readstat()
This is a particularly ugly on-failure bug, possibly security, since the lack of error handling here is covering up another class of bug: failure to handle copy_to_user() return values. The I4L API function ->readstat() returns an integer, and by looking at several existing driver implementations, it is clear that a negative return value was meant to indicate an error. Given that several drivers already return a negative value indicating an errno-style error, the current code would blindly accept that [negative] value as a valid amount of bytes read. Obvious damage ensues. Correcting ->readstat() handling to properly notice errors fixes the existing code to work correctly on error, and enables future patches to more easily indicate errors during operation. Signed-off-by: Jeff Garzik <jeff@garzik.org> Cc: Karsten Keil <kkeil@suse.de> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/isdn/i4l')
-rw-r--r--drivers/isdn/i4l/isdn_common.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index c3d79eef9e32..69aee2602aa6 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1134,9 +1134,12 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
1134 if (dev->drv[drvidx]->interface->readstat) { 1134 if (dev->drv[drvidx]->interface->readstat) {
1135 if (count > dev->drv[drvidx]->stavail) 1135 if (count > dev->drv[drvidx]->stavail)
1136 count = dev->drv[drvidx]->stavail; 1136 count = dev->drv[drvidx]->stavail;
1137 len = dev->drv[drvidx]->interface-> 1137 len = dev->drv[drvidx]->interface->readstat(buf, count,
1138 readstat(buf, count, drvidx, 1138 drvidx, isdn_minor2chan(minor));
1139 isdn_minor2chan(minor)); 1139 if (len < 0) {
1140 retval = len;
1141 goto out;
1142 }
1140 } else { 1143 } else {
1141 len = 0; 1144 len = 0;
1142 } 1145 }