From: Nicolin Chen <nicoleotsuka@gmail.com>
To: thierry.reding@gmail.com, airlied@linux.ie, jonathanh@nvidia.com
Cc: dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] drm/tegra: falcon: Validate firmware.vaddr with IS_ERR_OR_NULL
Date: Wed, 31 Oct 2018 18:44:20 -0700 [thread overview]
Message-ID: <20181101014420.13366-1-nicoleotsuka@gmail.com> (raw)
The firmware.vaddr might be assigned with an error code instead of
NULL, so this patch uses an IS_ERR_OR_NULL check to fix below bug.
Unable to handle kernel paging request at virtual address fffffffffffffff0
[...]
pc : falcon_load_firmware+0x80/0x358 [tegra_drm]
lr : falcon_load_firmware+0x2b4/0x358 [tegra_drm]
sp : ffff000010feb4a0
[...]
Call trace:
falcon_load_firmware+0x80/0x358 [tegra_drm]
vic_init+0x74/0x158 [tegra_drm]
host1x_device_init+0x58/0x108 [host1x]
tegra_drm_load+0xdc/0x2b8 [tegra_drm]
Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
---
drivers/gpu/drm/tegra/falcon.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/tegra/falcon.c b/drivers/gpu/drm/tegra/falcon.c
index f685e72949d1..9126d4fc5933 100644
--- a/drivers/gpu/drm/tegra/falcon.c
+++ b/drivers/gpu/drm/tegra/falcon.c
@@ -141,9 +141,10 @@ int falcon_load_firmware(struct falcon *falcon)
/* allocate iova space for the firmware */
falcon->firmware.vaddr = falcon->ops->alloc(falcon, firmware->size,
&falcon->firmware.paddr);
- if (!falcon->firmware.vaddr) {
+ if (IS_ERR_OR_NULL(falcon->firmware.vaddr)) {
dev_err(falcon->dev, "dma memory mapping failed\n");
- return -ENOMEM;
+ err = PTR_ERR(falcon->firmware.vaddr);
+ return err ? err : -ENOMEM;
}
/* copy firmware image into local area. this also ensures endianness */
--
2.17.1
reply other threads:[~2018-11-01 1:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181101014420.13366-1-nicoleotsuka@gmail.com \
--to=nicoleotsuka@gmail.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®