media: vivid: check if the cec_adapter is valid
authorHans Verkuil <hverkuil@xs4all.nl>
Mon, 12 Feb 2018 11:45:32 +0000 (06:45 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Apr 2018 07:36:25 +0000 (09:36 +0200)
commit ed356f110403f6acc64dcbbbfdc38662ab9b06c2 upstream.

If CEC is not enabled for the vivid driver, then the adap pointer is NULL
and 'adap->phys_addr' will fail.

Cc: <stable@vger.kernel.org> # for v4.12 and up
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/platform/vivid/vivid-vid-common.c

index f0f423c7ca410bb64e034523e13adfd2b806e42f..6f6d4df1e8a884e8aca5a9427f3861d1ee9cd41d 100644 (file)
@@ -858,7 +858,8 @@ int vidioc_g_edid(struct file *file, void *_fh,
                return -EINVAL;
        if (edid->start_block + edid->blocks > dev->edid_blocks)
                edid->blocks = dev->edid_blocks - edid->start_block;
-       cec_set_edid_phys_addr(dev->edid, dev->edid_blocks * 128, adap->phys_addr);
+       if (adap)
+               cec_set_edid_phys_addr(dev->edid, dev->edid_blocks * 128, adap->phys_addr);
        memcpy(edid->edid, dev->edid + edid->start_block * 128, edid->blocks * 128);
        return 0;
 }