From: Dan Carpenter <dan.carpenter@linaro.org>
To: Donald Robson <donald.robson@imgtec.com>
Cc: Frank Binns <frank.binns@imgtec.com>,
Matt Coster <matt.coster@imgtec.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
Sarah Walker <sarah.walker@imgtec.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [PATCH] drm/imagination: Move dereference after NULL check in pvr_mmu_backing_page_init()
Date: Wed, 6 Dec 2023 17:37:24 +0300 [thread overview]
Message-ID: <13f4278e-af9c-4092-9196-bc0e6b76f1eb@moroto.mountain> (raw)
This code dereferences "page->pvr_dev" and then checked for NULL on the
next line. Re-order it to avoid a potential NULL pointer dereference.
Fixes: ff5f643de0bf ("drm/imagination: Add GEM and VM related code")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/gpu/drm/imagination/pvr_mmu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/imagination/pvr_mmu.c b/drivers/gpu/drm/imagination/pvr_mmu.c
index c8562bfc0dcd..4fe70610ed94 100644
--- a/drivers/gpu/drm/imagination/pvr_mmu.c
+++ b/drivers/gpu/drm/imagination/pvr_mmu.c
@@ -316,12 +316,14 @@ pvr_mmu_backing_page_init(struct pvr_mmu_backing_page *page,
static void
pvr_mmu_backing_page_fini(struct pvr_mmu_backing_page *page)
{
- struct device *dev = from_pvr_device(page->pvr_dev)->dev;
+ struct device *dev;
/* Do nothing if no allocation is present. */
if (!page->pvr_dev)
return;
+ dev = from_pvr_device(page->pvr_dev)->dev;
+
dma_unmap_page(dev, page->dma_addr, PVR_MMU_BACKING_PAGE_SIZE,
DMA_TO_DEVICE);
--
2.42.0
next reply other threads:[~2023-12-06 14:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 14:37 Dan Carpenter [this message]
2023-12-06 14:42 ` Frank Binns
2023-12-08 9:36 ` (subset) " Maxime Ripard
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=13f4278e-af9c-4092-9196-bc0e6b76f1eb@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=donald.robson@imgtec.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=frank.binns@imgtec.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matt.coster@imgtec.com \
--cc=mripard@kernel.org \
--cc=sarah.walker@imgtec.com \
--cc=tzimmermann@suse.de \
/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®