summaryrefslogtreecommitdiff
path: root/drivers/media/platform/mtk-vpu
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2016-09-07 20:10:27 +0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-21 17:09:34 +0300
commit211eba9e791e6f6f4c5945b7fabc1dba150075e4 (patch)
treefd5b20ed9a05cc28325773f428dc092606e479e4 /drivers/media/platform/mtk-vpu
parent67712beb2df027ff36ff6d19b1aeb1af213fac04 (diff)
downloadlinux-211eba9e791e6f6f4c5945b7fabc1dba150075e4.tar.xz
[media] VPU: mediatek: fix null pointer dereference on pdev
pdev is being null checked, however, prior to that it is being dereferenced by platform_get_drvdata. Move the assignments of vpu and run to after the pdev null check to avoid a potential null pointer dereference. Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Tiffany Lin <tiffany.lin@mediatek.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/platform/mtk-vpu')
-rw-r--r--drivers/media/platform/mtk-vpu/mtk_vpu.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c b/drivers/media/platform/mtk-vpu/mtk_vpu.c
index 63510de0147c..c3643d929167 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
@@ -534,9 +534,9 @@ static int load_requested_vpu(struct mtk_vpu *vpu,
int vpu_load_firmware(struct platform_device *pdev)
{
- struct mtk_vpu *vpu = platform_get_drvdata(pdev);
+ struct mtk_vpu *vpu;
struct device *dev = &pdev->dev;
- struct vpu_run *run = &vpu->run;
+ struct vpu_run *run;
const struct firmware *vpu_fw = NULL;
int ret;
@@ -545,6 +545,9 @@ int vpu_load_firmware(struct platform_device *pdev)
return -EINVAL;
}
+ vpu = platform_get_drvdata(pdev);
+ run = &vpu->run;
+
mutex_lock(&vpu->vpu_mutex);
if (vpu->fw_loaded) {
mutex_unlock(&vpu->vpu_mutex);