summaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/cx23885/cx23885-video.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2023-10-19 08:58:49 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2024-02-05 12:57:44 +0100
commit15126b916e39b0cb67026b0af3c014bfeb1f76b3 (patch)
tree1e5f1e580c301124aa3aa80ac7a50b44111e54bd /drivers/media/pci/cx23885/cx23885-video.c
parentmedia: tc358746: fix the pll calculating function (diff)
downloadlinux-15126b916e39b0cb67026b0af3c014bfeb1f76b3.tar.xz
linux-15126b916e39b0cb67026b0af3c014bfeb1f76b3.zip
media: pci: cx23885: check cx23885_vdev_init() return
cx23885_vdev_init() can return a NULL pointer, but that pointer is used in the next line without a check. Add a NULL pointer check and go to the error unwind if it is NULL. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reported-by: Sicong Huang <huangsicong@iie.ac.cn>
Diffstat (limited to '')
-rw-r--r--drivers/media/pci/cx23885/cx23885-video.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c
index 42fdcf992e48..7d4a409c433e 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -1354,6 +1354,10 @@ int cx23885_video_register(struct cx23885_dev *dev)
/* register Video device */
dev->video_dev = cx23885_vdev_init(dev, dev->pci,
&cx23885_video_template, "video");
+ if (!dev->video_dev) {
+ err = -ENOMEM;
+ goto fail_unreg;
+ }
dev->video_dev->queue = &dev->vb2_vidq;
dev->video_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
V4L2_CAP_AUDIO | V4L2_CAP_VIDEO_CAPTURE;
@@ -1382,6 +1386,10 @@ int cx23885_video_register(struct cx23885_dev *dev)
/* register VBI device */
dev->vbi_dev = cx23885_vdev_init(dev, dev->pci,
&cx23885_vbi_template, "vbi");
+ if (!dev->vbi_dev) {
+ err = -ENOMEM;
+ goto fail_unreg;
+ }
dev->vbi_dev->queue = &dev->vb2_vbiq;
dev->vbi_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
V4L2_CAP_AUDIO | V4L2_CAP_VBI_CAPTURE;