tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
authorYang Yingliang <yangyingliang@huawei.com>
Thu, 5 May 2022 12:46:21 +0000 (20:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 May 2022 07:47:28 +0000 (09:47 +0200)
commit8fcefb43ecfcba64becbd0cdc5d541ebdcee47fb
tree3a48b8ea652ec954e5a1b12512f2d94a9b1ba622
parent6d80857c4fc7bd6b697dd6b73641c4d10c47ca5f
tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()

commit 447ee1516f19f534a228dda237eddb202f23e163 upstream.

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.

Fixes: 5930cb3511df ("serial: driver for Conexant Digicolor USART")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Baruch Siach <baruch@tkos.co.il>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220505124621.1592697-1-yangyingliang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/digicolor-usart.c