]> git.proxmox.com Git - mirror_ubuntu-focal-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)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 18 Jun 2021 13:02:50 +0000 (15:02 +0200)
commit1c31c490d6ef90764ed750b4e2a0040552028aed
tree6991a1d2dd535ddefff9b5cf9467f82e7d1da5a6
parent81f08b080381068191620d62a3d358ec3abfc0f7
isdn: mISDNinfineon: check/cleanup ioremap failure correctly in setup_io

BugLink: https://bugs.launchpad.net/bugs/1931166
[ 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: Stefan Bader <stefan.bader@canonical.com>
drivers/isdn/hardware/mISDN/mISDNinfineon.c