linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/rockchip: vop: fix possible null-ptr-deref in vop_bind()
@ 2022-04-22  3:28 Yang Yingliang
  2022-05-02 22:24 ` Heiko Stuebner
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2022-04-22  3:28 UTC (permalink / raw)
  To: linux-kernel, linux-rockchip, linux-arm-kernel, dri-devel
  Cc: hjc, heiko, daniel, markyao0591

It will cause null-ptr-deref in resource_size(), if platform_get_resource()
returns NULL, move calling resource_size() after devm_ioremap_resource() that
will check 'res' to avoid null-ptr-deref.

Fixes: 2048e3286f34 ("drm: rockchip: Add basic drm driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 3e8d9e2d1b67..d53037531f40 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -2118,10 +2118,10 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
 	vop_win_init(vop);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	vop->len = resource_size(res);
 	vop->regs = devm_ioremap_resource(dev, res);
 	if (IS_ERR(vop->regs))
 		return PTR_ERR(vop->regs);
+	vop->len = resource_size(res);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 	if (res) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/rockchip: vop: fix possible null-ptr-deref in vop_bind()
  2022-04-22  3:28 [PATCH] drm/rockchip: vop: fix possible null-ptr-deref in vop_bind() Yang Yingliang
@ 2022-05-02 22:24 ` Heiko Stuebner
  0 siblings, 0 replies; 2+ messages in thread
From: Heiko Stuebner @ 2022-05-02 22:24 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, dri-devel, Yang Yingliang,
	linux-rockchip
  Cc: Heiko Stuebner, markyao0591, hjc, daniel

On Fri, 22 Apr 2022 11:28:54 +0800, Yang Yingliang wrote:
> It will cause null-ptr-deref in resource_size(), if platform_get_resource()
> returns NULL, move calling resource_size() after devm_ioremap_resource() that
> will check 'res' to avoid null-ptr-deref.

Applied, thanks!

[1/1] drm/rockchip: vop: fix possible null-ptr-deref in vop_bind()
      commit: f8c242908ad15bbd604d3bcb54961b7d454c43f8

Best regards,
-- 
Heiko Stuebner <heiko@sntech.de>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-02 22:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22  3:28 [PATCH] drm/rockchip: vop: fix possible null-ptr-deref in vop_bind() Yang Yingliang
2022-05-02 22:24 ` Heiko Stuebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).