summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2023-05-24 13:11:47 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-08-30 16:35:11 +0200
commit099e929e7477f37ca16738fc158d7101c0189ca1 (patch)
tree68f1eb92188261d98ef655f36edf7aaab4ff3966
parent690dd4780b3f4d755e4e7883e8c3d1b5052f6bf2 (diff)
downloadlinux-099e929e7477f37ca16738fc158d7101c0189ca1.tar.gz
linux-099e929e7477f37ca16738fc158d7101c0189ca1.tar.bz2
linux-099e929e7477f37ca16738fc158d7101c0189ca1.zip
media: platform: mediatek: vpu: fix NULL ptr dereference
[ Upstream commit 3df55cd773e8603b623425cc97b05e542854ad27 ] If pdev is NULL, then it is still dereferenced. This fixes this smatch warning: drivers/media/platform/mediatek/vpu/mtk_vpu.c:570 vpu_load_firmware() warn: address of NULL pointer 'pdev' Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: Yunfei Dong <yunfei.dong@mediatek.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/media/platform/mtk-vpu/mtk_vpu.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c b/drivers/media/platform/mtk-vpu/mtk_vpu.c
index 019a5e7e1a40..de5e732b1f0b 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
@@ -536,16 +536,18 @@ static int load_requested_vpu(struct mtk_vpu *vpu,
int vpu_load_firmware(struct platform_device *pdev)
{
struct mtk_vpu *vpu;
- struct device *dev = &pdev->dev;
+ struct device *dev;
struct vpu_run *run;
const struct firmware *vpu_fw = NULL;
int ret;
if (!pdev) {
- dev_err(dev, "VPU platform device is invalid\n");
+ pr_err("VPU platform device is invalid\n");
return -EINVAL;
}
+ dev = &pdev->dev;
+
vpu = platform_get_drvdata(pdev);
run = &vpu->run;