[PATCH] drm/imagination: Move dereference after NULL check in pvr_mmu_backing_page_init()
Frank Binns
Frank.Binns at imgtec.com
Wed Dec 6 14:42:17 UTC 2023
Hi Dan,
Thank you for the patch.
On Wed, 2023-12-06 at 17:37 +0300, Dan Carpenter wrote:
> 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 at linaro.org>
Reviewed-by: Frank Binns <frank.binns at imgtec.com>
> ---
> 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);
>
More information about the dri-devel
mailing list