media: tw686x: Fix oops on buffer alloc failure
[ Upstream commitpull/10/head5a1a2f63d8
] 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:f8afaa8dbc
("[media] tw686x: Introduce an interface to support multiple DMA modes") Signed-off-by: Krzysztof Ha?asa <khalasa@piap.pl> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
parent
ee83ce188e
commit
58119f9bd9
|
@ -1190,6 +1190,14 @@ int tw686x_video_init(struct tw686x_dev *dev)
|
||||||
return err;
|
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++) {
|
for (ch = 0; ch < max_channels(dev); ch++) {
|
||||||
struct tw686x_video_channel *vc = &dev->video_channels[ch];
|
struct tw686x_video_channel *vc = &dev->video_channels[ch];
|
||||||
struct video_device *vdev;
|
struct video_device *vdev;
|
||||||
|
@ -1198,9 +1206,6 @@ int tw686x_video_init(struct tw686x_dev *dev)
|
||||||
spin_lock_init(&vc->qlock);
|
spin_lock_init(&vc->qlock);
|
||||||
INIT_LIST_HEAD(&vc->vidq_queued);
|
INIT_LIST_HEAD(&vc->vidq_queued);
|
||||||
|
|
||||||
vc->dev = dev;
|
|
||||||
vc->ch = ch;
|
|
||||||
|
|
||||||
/* default settings */
|
/* default settings */
|
||||||
err = tw686x_set_standard(vc, V4L2_STD_NTSC);
|
err = tw686x_set_standard(vc, V4L2_STD_NTSC);
|
||||||
if (err)
|
if (err)
|
||||||
|
|
Loading…
Reference in New Issue