Commit 512f0b7
media: cx18: Fix invalid access to file *
Sice commit 7b9eb53 ("media: cx18: Access v4l2_fh from file")
all ioctl handlers have been ported to operate on the file * first
function argument.
The cx18 DVB layer calls cx18_init_on_first_open() when the driver needs
to start streaming. This function calls the s_input(), s_std() and
s_frequency() ioctl handlers directly, but being called from the driver
context, it doesn't have a valid file * to pass them. This causes
the ioctl handlers to deference an invalid pointer.
Fix this by moving the implementation of those ioctls to functions that
take a cx18 pointer instead of a file pointer, and turn the V4L2 ioctl
handlers into wrappers that get the cx18 from the file. When calling
from cx18_init_on_first_open(), pass the cx18 pointer directly. This
allows removing the fake fh in cx18_init_on_first_open().
The bug has been reported by Smatch:
--> 1223 cx18_s_input(NULL, &fh, video_input);
The patch adds a new dereference of "file" but some of the callers pass a
NULL pointer.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/aKL4OMWsESUdX8KQ@stanley.mountain/
Fixes: 7b9eb53 ("media: cx18: Access v4l2_fh from file")
Cc: stable@vger.kernel.org
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>1 parent 3a86608 commit 512f0b7
3 files changed
Lines changed: 27 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1136 | 1136 | | |
1137 | 1137 | | |
1138 | 1138 | | |
1139 | | - | |
1140 | 1139 | | |
1141 | 1140 | | |
1142 | | - | |
1143 | | - | |
1144 | 1141 | | |
1145 | 1142 | | |
1146 | 1143 | | |
| |||
1220 | 1217 | | |
1221 | 1218 | | |
1222 | 1219 | | |
1223 | | - | |
| 1220 | + | |
1224 | 1221 | | |
1225 | 1222 | | |
1226 | 1223 | | |
1227 | 1224 | | |
1228 | 1225 | | |
1229 | | - | |
1230 | | - | |
| 1226 | + | |
| 1227 | + | |
1231 | 1228 | | |
1232 | 1229 | | |
1233 | 1230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
524 | | - | |
| 524 | + | |
525 | 525 | | |
526 | | - | |
527 | | - | |
528 | 526 | | |
529 | 527 | | |
530 | 528 | | |
| |||
558 | 556 | | |
559 | 557 | | |
560 | 558 | | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
561 | 564 | | |
562 | 565 | | |
563 | 566 | | |
| |||
570 | 573 | | |
571 | 574 | | |
572 | 575 | | |
573 | | - | |
| 576 | + | |
574 | 577 | | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| |||
585 | 585 | | |
586 | 586 | | |
587 | 587 | | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
588 | 594 | | |
589 | 595 | | |
590 | 596 | | |
| |||
593 | 599 | | |
594 | 600 | | |
595 | 601 | | |
596 | | - | |
| 602 | + | |
597 | 603 | | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | 604 | | |
602 | 605 | | |
603 | 606 | | |
| |||
642 | 645 | | |
643 | 646 | | |
644 | 647 | | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
645 | 653 | | |
646 | 654 | | |
647 | 655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments