aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/upd64083.c
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-01-30 21:25:41 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:35:10 -0500
commit62d50addf0774115adaa9e01e09099c3d7daa13d (patch)
tree5490c0acef3aa645c6974437b3ca7a508ed755a3 /drivers/media/video/upd64083.c
parente7b58f5259a81dbd9fbfea79408d272f44eb894f (diff)
V4L/DVB (5163): Add checks for CAP_SYS_ADMIN to VIDIOC_DBG_G_REGISTER
Before, root privileges were only needed to set hardware registers, not to read them. On some hardware, reading from the wrong place at the wrong time can hang the machine. So, to be consistent, root privileges are required to read registers on all hardware. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/upd64083.c')
-rw-r--r--drivers/media/video/upd64083.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c
index 3f0eec0cdb45..8852903e7a92 100644
--- a/drivers/media/video/upd64083.c
+++ b/drivers/media/video/upd64083.c
@@ -140,26 +140,18 @@ static int upd64083_command(struct i2c_client *client, unsigned int cmd, void *a
140 140
141#ifdef CONFIG_VIDEO_ADV_DEBUG 141#ifdef CONFIG_VIDEO_ADV_DEBUG
142 case VIDIOC_DBG_G_REGISTER: 142 case VIDIOC_DBG_G_REGISTER:
143 {
144 struct v4l2_register *reg = arg;
145
146 if (reg->i2c_id != I2C_DRIVERID_UPD64083)
147 return -EINVAL;
148 reg->val = upd64083_read(client, reg->reg & 0xff);
149 break;
150 }
151
152 case VIDIOC_DBG_S_REGISTER: 143 case VIDIOC_DBG_S_REGISTER:
153 { 144 {
154 struct v4l2_register *reg = arg; 145 struct v4l2_register *reg = arg;
155 u8 addr = reg->reg & 0xff;
156 u8 val = reg->val & 0xff;
157 146
158 if (reg->i2c_id != I2C_DRIVERID_UPD64083) 147 if (reg->i2c_id != I2C_DRIVERID_UPD64083)
159 return -EINVAL; 148 return -EINVAL;
160 if (!capable(CAP_SYS_ADMIN)) 149 if (!capable(CAP_SYS_ADMIN))
161 return -EPERM; 150 return -EPERM;
162 upd64083_write(client, addr, val); 151 if (cmd == VIDIOC_DBG_G_REGISTER)
152 reg->val = upd64083_read(client, reg->reg & 0xff);
153 else
154 upd64083_write(client, reg->reg & 0xff, reg->val & 0xff);
163 break; 155 break;
164 } 156 }
165#endif 157#endif