Commit c17db233 authored by Dan Carpenter's avatar Dan Carpenter Committed by Chen Zhongjin
Browse files

can: sja1000: fix use after free in ems_pcmcia_add_card()

stable inclusion
from stable-v4.19.221
commit ccf070183e4655824936c0f96c4a2bcca93419aa
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9S254
CVE: CVE-2021-47521

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

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

commit 3ec6ca6b upstream.

If the last channel is not available then "dev" is freed.  Fortunately,
we can just use "pdev->irq" instead.

Also we should check if at least one channel was set up.

Fixes: fd734c6f ("can/sja1000: add driver for EMS PCMCIA card")
Link: https://lore.kernel.org/all/20211124145041.GB13656@kili


Cc: stable@vger.kernel.org
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
Tested-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarChen Zhongjin <chenzhongjin@huawei.com>
parent 9e57bb44
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment