]> git.baikalelectronics.ru Git - kernel.git/commit
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:33:31 +0000 (09:33 +0100)
commit7297c66997d9c925570d74c2895a59f1247d0558
treefa95100a898206230a8cb33a3a0d696275194f1a
parent64efecbf4f24411352a84e28dd47faa608446d37
PCI: switchtec: Return -EFAULT for copy_to_user() errors

[ Upstream commit e66bbf7e95479052c7270b067a17f50004f3b280 ]

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: 1293aa328c73 ("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