]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.129/media-tw686x-fix-oops-on-buffer-alloc-failure.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.129 / media-tw686x-fix-oops-on-buffer-alloc-failure.patch
CommitLineData
47f38bc9
GKH
1From foo@baz Fri Sep 21 09:36:02 CEST 2018
2From: Krzysztof Ha?asa <khalasa@piap.pl>
3Date: Thu, 28 Jun 2018 17:45:07 -0400
4Subject: media: tw686x: Fix oops on buffer alloc failure
5
6From: Krzysztof Ha?asa <khalasa@piap.pl>
7
8[ Upstream commit 5a1a2f63d840dc2631505b607e11ff65ac1b7d3c ]
9
10The error path currently calls tw686x_video_free() which requires
11vc->dev to be initialized, causing a NULL dereference on uninitizalized
12channels.
13
14Fix this by setting the vc->dev fields for all the channels first.
15
16Fixes: f8afaa8dbc0d ("[media] tw686x: Introduce an interface to support multiple DMA modes")
17
18Signed-off-by: Krzysztof Ha?asa <khalasa@piap.pl>
19Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
20Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
21Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
22Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23---
24 drivers/media/pci/tw686x/tw686x-video.c | 11 ++++++++---
25 1 file changed, 8 insertions(+), 3 deletions(-)
26
27--- a/drivers/media/pci/tw686x/tw686x-video.c
28+++ b/drivers/media/pci/tw686x/tw686x-video.c
29@@ -1190,6 +1190,14 @@ int tw686x_video_init(struct tw686x_dev
30 return err;
31 }
32
33+ /* Initialize vc->dev and vc->ch for the error path */
34+ for (ch = 0; ch < max_channels(dev); ch++) {
35+ struct tw686x_video_channel *vc = &dev->video_channels[ch];
36+
37+ vc->dev = dev;
38+ vc->ch = ch;
39+ }
40+
41 for (ch = 0; ch < max_channels(dev); ch++) {
42 struct tw686x_video_channel *vc = &dev->video_channels[ch];
43 struct video_device *vdev;
44@@ -1198,9 +1206,6 @@ int tw686x_video_init(struct tw686x_dev
45 spin_lock_init(&vc->qlock);
46 INIT_LIST_HEAD(&vc->vidq_queued);
47
48- vc->dev = dev;
49- vc->ch = ch;
50-
51 /* default settings */
52 err = tw686x_set_standard(vc, V4L2_STD_NTSC);
53 if (err)