pinctrl: renesas: rzn1: Fix possible null-ptr-deref in sh_pfc_map_resources()
authorYang Yingliang <yangyingliang@huawei.com>
Fri, 29 Apr 2022 08:26:37 +0000 (16:26 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:22:42 +0000 (10:22 +0200)
commitc16b59d445135c8026a04e388d8b2762feaa3b3b
tree3c79ede2acc90313cdceb2f2eef562646ab2a2e4
parent50c292b469d4b5f7a6f1c8dadab4d78c136738f3
pinctrl: renesas: rzn1: Fix possible null-ptr-deref in sh_pfc_map_resources()

[ Upstream commit 2f661477c2bb8068194dbba9738d05219f111c6e ]

It will cause null-ptr-deref when using 'res', if platform_get_resource()
returns NULL, so move using 'res' after devm_ioremap_resource() that
will check it to avoid null-ptr-deref.
And use devm_platform_get_and_ioremap_resource() to simplify code.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20220429082637.1308182-2-yangyingliang@huawei.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pinctrl/renesas/pinctrl-rzn1.c