* [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null
@ 2016-11-16 19:16 Colin King
2016-11-18 9:49 ` Matthias Brugger
2016-11-21 11:16 ` andrew-ct chen
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2016-11-16 19:16 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Matthias Brugger, Hans Verkuil,
Wei Yongjun, Andrew-CT Chen, linux-media, linux-arm-kernel,
linux-mediatek
Cc: linux-kernel
From: Colin Ian King <colin.king@canonical.com>
pdev is dereferenced using platform_get_drvdata before a check to
see if it is null, hence there could be a potential null pointer
dereference issue. Instead, first check if pdev is null and only then
deference pdev when initializing vpu.
Found with static analysis by CoverityScan, CID 1357797
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/media/platform/mtk-vpu/mtk_vpu.c | 6 ++++--
1 file 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 c9bf58c..41f31b2 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
@@ -523,9 +523,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;
@@ -533,6 +533,8 @@ int vpu_load_firmware(struct platform_device *pdev)
dev_err(dev, "VPU platform device is invalid\n");
return -EINVAL;
}
+ vpu = platform_get_drvdata(pdev);
+ run = &vpu->run;
mutex_lock(&vpu->vpu_mutex);
if (vpu->fw_loaded) {
--
2.10.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null
2016-11-16 19:16 [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null Colin King
@ 2016-11-18 9:49 ` Matthias Brugger
2016-11-21 11:16 ` andrew-ct chen
1 sibling, 0 replies; 3+ messages in thread
From: Matthias Brugger @ 2016-11-18 9:49 UTC (permalink / raw)
To: Colin King, Mauro Carvalho Chehab, Hans Verkuil, Wei Yongjun,
Andrew-CT Chen, linux-media, linux-arm-kernel, linux-mediatek
Cc: linux-kernel
On 16/11/16 20:16, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> pdev is dereferenced using platform_get_drvdata before a check to
> see if it is null, hence there could be a potential null pointer
> dereference issue. Instead, first check if pdev is null and only then
> deference pdev when initializing vpu.
>
> Found with static analysis by CoverityScan, CID 1357797
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
> drivers/media/platform/mtk-vpu/mtk_vpu.c | 6 ++++--
> 1 file 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 c9bf58c..41f31b2 100644
> --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
> +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> @@ -523,9 +523,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;
>
> @@ -533,6 +533,8 @@ int vpu_load_firmware(struct platform_device *pdev)
> dev_err(dev, "VPU platform device is invalid\n");
> return -EINVAL;
> }
> + vpu = platform_get_drvdata(pdev);
> + run = &vpu->run;
>
> mutex_lock(&vpu->vpu_mutex);
> if (vpu->fw_loaded) {
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null
2016-11-16 19:16 [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null Colin King
2016-11-18 9:49 ` Matthias Brugger
@ 2016-11-21 11:16 ` andrew-ct chen
1 sibling, 0 replies; 3+ messages in thread
From: andrew-ct chen @ 2016-11-21 11:16 UTC (permalink / raw)
To: Colin King
Cc: Mauro Carvalho Chehab, Matthias Brugger, Hans Verkuil,
Wei Yongjun, linux-media, linux-arm-kernel, linux-mediatek,
linux-kernel
On Wed, 2016-11-16 at 19:16 +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> pdev is dereferenced using platform_get_drvdata before a check to
> see if it is null, hence there could be a potential null pointer
> dereference issue. Instead, first check if pdev is null and only then
> deference pdev when initializing vpu.
>
> Found with static analysis by CoverityScan, CID 1357797
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
Reviewed-by: Andrew-CT Chen <andrew-ct.chen@mediatek.com>
> drivers/media/platform/mtk-vpu/mtk_vpu.c | 6 ++++--
> 1 file 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 c9bf58c..41f31b2 100644
> --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
> +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> @@ -523,9 +523,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;
>
> @@ -533,6 +533,8 @@ int vpu_load_firmware(struct platform_device *pdev)
> dev_err(dev, "VPU platform device is invalid\n");
> return -EINVAL;
> }
> + vpu = platform_get_drvdata(pdev);
> + run = &vpu->run;
>
> mutex_lock(&vpu->vpu_mutex);
> if (vpu->fw_loaded) {
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-21 11:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-16 19:16 [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null Colin King
2016-11-18 9:49 ` Matthias Brugger
2016-11-21 11:16 ` andrew-ct chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).