All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tw686x: Fix oops on buffer alloc failure
@ 2018-06-28 21:45 Ezequiel Garcia
  0 siblings, 0 replies; 10+ messages in thread
From: Ezequiel Garcia @ 2018-06-28 21:45 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, Krzysztof Hałasa

From: Krzysztof Hałasa <khalasa@piap.pl>

The error path currently calls tw686x_video_free() which requires
vc->dev to be initialized, causing a NULL dereference on uninitizalized
channels.

Fix this by setting the vc->dev fields for all the channels first.

Fixes: f8afaa8dbc0d ("[media] tw686x: Introduce an interface to support multiple DMA modes")
Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
---
 drivers/media/pci/tw686x/tw686x-video.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c
index 0ea8dd44026c..3a06c000f97b 100644
--- a/drivers/media/pci/tw686x/tw686x-video.c
+++ b/drivers/media/pci/tw686x/tw686x-video.c
@@ -1190,6 +1190,14 @@ int tw686x_video_init(struct tw686x_dev *dev)
 			return err;
 	}
 
+	/* Initialize vc->dev and vc->ch for the error path */
+	for (ch = 0; ch < max_channels(dev); ch++) {
+		struct tw686x_video_channel *vc = &dev->video_channels[ch];
+
+		vc->dev = dev;
+		vc->ch = ch;
+	}
+
 	for (ch = 0; ch < max_channels(dev); ch++) {
 		struct tw686x_video_channel *vc = &dev->video_channels[ch];
 		struct video_device *vdev;
@@ -1198,9 +1206,6 @@ int tw686x_video_init(struct tw686x_dev *dev)
 		spin_lock_init(&vc->qlock);
 		INIT_LIST_HEAD(&vc->vidq_queued);
 
-		vc->dev = dev;
-		vc->ch = ch;
-
 		/* default settings */
 		err = tw686x_set_standard(vc, V4L2_STD_NTSC);
 		if (err)
-- 
2.18.0.rc2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-06-28 21:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <590ADAB1.1040501@suntec.net>
2017-05-10  9:48 ` [PCIE device driver: tw686x] I have some problems with tw686x and I need help Krzysztof Hałasa
2017-05-10  9:51   ` [PATCH] TW686x: Fix OOPS on buffer alloc failure Krzysztof Hałasa
2017-05-10 16:18     ` Ezequiel Garcia
2017-05-11  7:41       ` Krzysztof Hałasa
2017-05-11 16:04         ` Ezequiel Garcia
2017-05-12  4:39           ` Krzysztof Hałasa
     [not found]             ` <b088a7cd-7585-5235-224d-a90ea9042c24@xs4all.nl>
2017-06-23  8:18               ` Krzysztof Hałasa
2017-06-23 14:52                 ` Ezequiel Garcia
     [not found]       ` <5913C1BB.8000103@suntec.net>
2017-05-11  8:02         ` Krzysztof Hałasa
2018-06-28 21:45 [PATCH] tw686x: Fix oops " Ezequiel Garcia

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.