From patchwork Mon Jun 26 17:12:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13293241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DB70AEB64D7 for ; Mon, 26 Jun 2023 17:12:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0D31E10E0CA; Mon, 26 Jun 2023 17:12:43 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by gabe.freedesktop.org (Postfix) with ESMTP id 173FE10E0CA for ; Mon, 26 Jun 2023 17:12:40 +0000 (UTC) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8AxTccGx5lkmoMCAA--.3834S3; Tue, 27 Jun 2023 01:12:38 +0800 (CST) Received: from openarena.loongson.cn (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxxswGx5lkYhgKAA--.21854S2; Tue, 27 Jun 2023 01:12:38 +0800 (CST) From: Sui Jingfeng To: Tomi Valkeinen , David Airlie , Daniel Vetter Subject: [PATCH] drm/omap: Checking the mapping returned by vmap() Date: Tue, 27 Jun 2023 01:12:38 +0800 Message-Id: <20230626171238.667533-1-suijingfeng@loongson.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxxswGx5lkYhgKAA--.21854S2 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxJr1fKrW3GFy8Kw4xurWrCrX_yoW8uFy5p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mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Because vmap() function could fail. Also don't let omap_gem_vaddr() function signature (declaration) dangling there, as it will only get defined when CONFIG_DRM_FBDEV_EMULATION=y. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/omapdrm/omap_fbdev.c | 10 ++++++++-- drivers/gpu/drm/omapdrm/omap_gem.h | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index b7ccce0704a3..2c88aa1008d8 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c @@ -197,6 +197,11 @@ static int omap_fbdev_create(struct drm_fb_helper *helper, drm_fb_helper_fill_info(fbi, helper, sizes); fbi->screen_buffer = omap_gem_vaddr(bo); + if (!fbi->screen_buffer) { + ret = -ENOMEM; + goto err_release_fbi; + } + fbi->screen_size = bo->size; fbi->fix.smem_start = dma_addr; fbi->fix.smem_len = bo->size; @@ -210,14 +215,15 @@ static int omap_fbdev_create(struct drm_fb_helper *helper, fbi->fix.ywrapstep = 1; } - DBG("par=%p, %dx%d", fbi->par, fbi->var.xres, fbi->var.yres); DBG("allocated %dx%d fb", fb->width, fb->height); return 0; -fail: +err_release_fbi: + drm_fb_helper_release_info(helper); +fail: if (ret) { if (fb) drm_framebuffer_remove(fb); diff --git a/drivers/gpu/drm/omapdrm/omap_gem.h b/drivers/gpu/drm/omapdrm/omap_gem.h index 4d4488939f6b..7e8c41b72aae 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.h +++ b/drivers/gpu/drm/omapdrm/omap_gem.h @@ -48,7 +48,10 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size, struct sg_table *sgt); int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file, union omap_gem_size gsize, u32 flags, u32 *handle); + +#ifdef CONFIG_DRM_FBDEV_EMULATION void *omap_gem_vaddr(struct drm_gem_object *obj); +#endif /* Dumb Buffers Interface */ int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,