Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1523763
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Colin King <colin.king@canonical.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null |
| Date | Wed, 16 Nov 2016 20:20:01 +0100 |
| Message-ID | <sEdUt-70N-11@gated-at.bofh.it> (permalink) |
| X-Mailer | git-send-email 2.10.2 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset="utf-8" |
| Content-Transfer-Encoding | 8bit |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 41 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | linux-kernel@vger.kernel.org |
| X-Original-Date | Wed, 16 Nov 2016 19:16:50 +0000 |
| X-Original-Message-ID | <20161116191650.11486-1-colin.king@canonical.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1523763 |
Show key headers only | View raw
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
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null Colin King <colin.king@canonical.com> - 2016-11-16 20:20 +0100 Re: [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null Matthias Brugger <mbrugger@suse.com> - 2016-11-18 11:00 +0100 Re: [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null andrew-ct chen <andrew-ct.chen@mediatek.com> - 2016-11-21 12:20 +0100
csiph-web