PCI: switchtec: Return -EFAULT for copy_to_user() errors
authorBjorn Helgaas <bhelgaas@google.com>
Fri, 16 Dec 2022 16:21:26 +0000 (10:21 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:39:37 +0000 (09:39 +0100)
commit707d954d9b5c4defcdead96e232e9f655ae596bd
treecb5cf23c3439c50368b3a5b90c2874ab2bf91912
parent53b65fa40c01ad02c8b4640834344bae9ef9b61b
PCI: switchtec: Return -EFAULT for copy_to_user() errors

[ Upstream commit ddc10938e08cd7aac63d8385f7305f7889df5179 ]

switchtec_dev_read() didn't handle copy_to_user() errors correctly: it
assigned "rc = -EFAULT", but actually returned either "size", -ENXIO, or
-EBADMSG instead.

Update the failure cases to unlock mrpc_mutex and return -EFAULT directly.

Link: https://lore.kernel.org/r/20221216162126.207863-3-helgaas@kernel.org
Fixes: 080b47def5e5 ("MicroSemi Switchtec management interface driver")
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pci/switch/switchtec.c