|
26 | 26 |
|
27 | 27 | void CI_handle(struct av7110 *av7110, u8 *data, u16 len)
|
28 | 28 | {
|
| 29 | + unsigned slot_num; |
| 30 | + |
29 | 31 | dprintk(8, "av7110:%p\n", av7110);
|
30 | 32 |
|
31 | 33 | if (len < 3)
|
32 | 34 | return;
|
33 | 35 | switch (data[0]) {
|
34 | 36 | case CI_MSG_CI_INFO:
|
35 |
| - if (data[2] != 1 && data[2] != 2) |
| 37 | + if (data[2] != 1 && data[2] != MAX_CI_SLOTS) |
36 | 38 | break;
|
| 39 | + |
| 40 | + slot_num = array_index_nospec(data[2] - 1, MAX_CI_SLOTS); |
| 41 | + |
37 | 42 | switch (data[1]) {
|
38 | 43 | case 0:
|
39 |
| - av7110->ci_slot[data[2] - 1].flags = 0; |
| 44 | + av7110->ci_slot[slot_num].flags = 0; |
40 | 45 | break;
|
41 | 46 | case 1:
|
42 |
| - av7110->ci_slot[data[2] - 1].flags |= CA_CI_MODULE_PRESENT; |
| 47 | + av7110->ci_slot[slot_num].flags |= CA_CI_MODULE_PRESENT; |
43 | 48 | break;
|
44 | 49 | case 2:
|
45 |
| - av7110->ci_slot[data[2] - 1].flags |= CA_CI_MODULE_READY; |
| 50 | + av7110->ci_slot[slot_num].flags |= CA_CI_MODULE_READY; |
46 | 51 | break;
|
47 | 52 | }
|
48 | 53 | break;
|
@@ -262,15 +267,19 @@ static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
|
262 | 267 | case CA_GET_SLOT_INFO:
|
263 | 268 | {
|
264 | 269 | struct ca_slot_info *info = (struct ca_slot_info *)parg;
|
| 270 | + unsigned int slot_num; |
265 | 271 |
|
266 | 272 | if (info->num < 0 || info->num > 1) {
|
267 | 273 | mutex_unlock(&av7110->ioctl_mutex);
|
268 | 274 | return -EINVAL;
|
269 | 275 | }
|
270 |
| - av7110->ci_slot[info->num].num = info->num; |
271 |
| - av7110->ci_slot[info->num].type = FW_CI_LL_SUPPORT(av7110->arm_app) ? |
272 |
| - CA_CI_LINK : CA_CI; |
273 |
| - memcpy(info, &av7110->ci_slot[info->num], sizeof(struct ca_slot_info)); |
| 276 | + slot_num = array_index_nospec(info->num, MAX_CI_SLOTS); |
| 277 | + |
| 278 | + av7110->ci_slot[slot_num].num = info->num; |
| 279 | + av7110->ci_slot[slot_num].type = FW_CI_LL_SUPPORT(av7110->arm_app) ? |
| 280 | + CA_CI_LINK : CA_CI; |
| 281 | + memcpy(info, &av7110->ci_slot[slot_num], |
| 282 | + sizeof(struct ca_slot_info)); |
274 | 283 | break;
|
275 | 284 | }
|
276 | 285 |
|
|
0 commit comments