]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
isdn: mISDNinfineon: check/cleanup ioremap failure correctly in setup_io
authorPhillip Potter <phil@philpotter.co.uk>
Mon, 3 May 2021 11:57:08 +0000 (13:57 +0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Thu, 15 Jul 2021 17:22:44 +0000 (19:22 +0200)
commit41aadb9ff5d5108661be3f3570bf8e50605cb84e
treeee0d1d9fcee36cf9452c90c7802e303de26d565e
parent524b75b2edcbf0207dc4abddfb1ad544c53760b4
isdn: mISDNinfineon: check/cleanup ioremap failure correctly in setup_io

BugLink: https://bugs.launchpad.net/bugs/1931896
[ Upstream commit c446f0d4702d316e1c6bf621f70e79678d28830a ]

Move hw->cfg.mode and hw->addr.mode assignments from hw->ci->cfg_mode
and hw->ci->addr_mode respectively, to be before the subsequent checks
for memory IO mode (and possible ioremap calls in this case).

Also introduce ioremap error checks at both locations. This allows
resources to be properly freed on ioremap failure, as when the caller
of setup_io then subsequently calls release_io via its error path,
release_io can now correctly determine the mode as it has been set
before the ioremap call.

Finally, refactor release_io function so that it will call
release_mem_region in the memory IO case, regardless of whether or not
hw->cfg.p/hw->addr.p are NULL. This means resources are then properly
released on failure.

This properly implements the original reverted commit (d721fe99f6ad)
from the University of Minnesota, whilst also implementing the ioremap
check for the hw->ci->cfg_mode if block as well.

Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
Link: https://lore.kernel.org/r/20210503115736.2104747-42-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/isdn/hardware/mISDN/mISDNinfineon.c