Commit 45401662 authored by Yang Yingliang's avatar Yang Yingliang Committed by Cheng Yu
Browse files

drm/rockchip: vop: fix possible null-ptr-deref in vop_bind()

stable inclusion
from stable-v4.19.247
commit 6ff986e057bf28e2f7690dad410768b2270f9453
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBP1K1
CVE: CVE-2022-49491

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6ff986e057bf28e2f7690dad410768b2270f9453



--------------------------------

[ Upstream commit f8c24290 ]

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: 2048e328 ("drm: rockchip: Add basic drm driver")
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220422032854.2995175-1-yangyingliang@huawei.com


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarCheng Yu <serein.chengyu@huawei.com>
parent 54ad6c45
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1595,10 +1595,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);

	vop->regsbak = devm_kzalloc(dev, vop->len, GFP_KERNEL);
	if (!vop->regsbak)