diff options
author | Johan Hovold <johan@kernel.org> | 2019-08-05 06:00:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-08-05 13:25:48 -0400 |
commit | c3953a3c2d3175d2f9f0304c9a1ba89e7743c5e4 (patch) | |
tree | 07c316120fb7552531896ab03187c67b4038fada /drivers/nfc | |
parent | 5e5412c365a32e452daa762eac36121cb8a370bb (diff) |
NFC: nfcmrvl: fix gpio-handling regression
Fix two reset-gpio sanity checks which were never converted to use
gpio_is_valid(), and make sure to use -EINVAL to indicate a missing
reset line also for the UART-driver module parameter and for the USB
driver.
This specifically prevents the UART and USB drivers from incidentally
trying to request and use gpio 0, and also avoids triggering a WARN() in
gpio_to_desc() during probe when no valid reset line has been specified.
Fixes: e33a3f84f88f ("NFC: nfcmrvl: allow gpio 0 for reset signalling")
Reported-by: syzbot+cf35b76f35e068a1107f@syzkaller.appspotmail.com
Tested-by: syzbot+cf35b76f35e068a1107f@syzkaller.appspotmail.com
Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/nfc')
-rw-r--r-- | drivers/nfc/nfcmrvl/main.c | 4 | ||||
-rw-r--r-- | drivers/nfc/nfcmrvl/uart.c | 4 | ||||
-rw-r--r-- | drivers/nfc/nfcmrvl/usb.c | 1 |
3 files changed, 5 insertions, 4 deletions
diff --git a/drivers/nfc/nfcmrvl/main.c b/drivers/nfc/nfcmrvl/main.c index e65d027b91fa..529be35ac178 100644 --- a/drivers/nfc/nfcmrvl/main.c +++ b/drivers/nfc/nfcmrvl/main.c | |||
@@ -244,7 +244,7 @@ void nfcmrvl_chip_reset(struct nfcmrvl_private *priv) | |||
244 | /* Reset possible fault of previous session */ | 244 | /* Reset possible fault of previous session */ |
245 | clear_bit(NFCMRVL_PHY_ERROR, &priv->flags); | 245 | clear_bit(NFCMRVL_PHY_ERROR, &priv->flags); |
246 | 246 | ||
247 | if (priv->config.reset_n_io) { | 247 | if (gpio_is_valid(priv->config.reset_n_io)) { |
248 | nfc_info(priv->dev, "reset the chip\n"); | 248 | nfc_info(priv->dev, "reset the chip\n"); |
249 | gpio_set_value(priv->config.reset_n_io, 0); | 249 | gpio_set_value(priv->config.reset_n_io, 0); |
250 | usleep_range(5000, 10000); | 250 | usleep_range(5000, 10000); |
@@ -255,7 +255,7 @@ void nfcmrvl_chip_reset(struct nfcmrvl_private *priv) | |||
255 | 255 | ||
256 | void nfcmrvl_chip_halt(struct nfcmrvl_private *priv) | 256 | void nfcmrvl_chip_halt(struct nfcmrvl_private *priv) |
257 | { | 257 | { |
258 | if (priv->config.reset_n_io) | 258 | if (gpio_is_valid(priv->config.reset_n_io)) |
259 | gpio_set_value(priv->config.reset_n_io, 0); | 259 | gpio_set_value(priv->config.reset_n_io, 0); |
260 | } | 260 | } |
261 | 261 | ||
diff --git a/drivers/nfc/nfcmrvl/uart.c b/drivers/nfc/nfcmrvl/uart.c index 9a22056e8d9e..e5a622ce4b95 100644 --- a/drivers/nfc/nfcmrvl/uart.c +++ b/drivers/nfc/nfcmrvl/uart.c | |||
@@ -26,7 +26,7 @@ | |||
26 | static unsigned int hci_muxed; | 26 | static unsigned int hci_muxed; |
27 | static unsigned int flow_control; | 27 | static unsigned int flow_control; |
28 | static unsigned int break_control; | 28 | static unsigned int break_control; |
29 | static unsigned int reset_n_io; | 29 | static int reset_n_io = -EINVAL; |
30 | 30 | ||
31 | /* | 31 | /* |
32 | ** NFCMRVL NCI OPS | 32 | ** NFCMRVL NCI OPS |
@@ -231,5 +231,5 @@ MODULE_PARM_DESC(break_control, "Tell if UART driver must drive break signal."); | |||
231 | module_param(hci_muxed, uint, 0); | 231 | module_param(hci_muxed, uint, 0); |
232 | MODULE_PARM_DESC(hci_muxed, "Tell if transport is muxed in HCI one."); | 232 | MODULE_PARM_DESC(hci_muxed, "Tell if transport is muxed in HCI one."); |
233 | 233 | ||
234 | module_param(reset_n_io, uint, 0); | 234 | module_param(reset_n_io, int, 0); |
235 | MODULE_PARM_DESC(reset_n_io, "GPIO that is wired to RESET_N signal."); | 235 | MODULE_PARM_DESC(reset_n_io, "GPIO that is wired to RESET_N signal."); |
diff --git a/drivers/nfc/nfcmrvl/usb.c b/drivers/nfc/nfcmrvl/usb.c index 945cc903d8f1..888e298f610b 100644 --- a/drivers/nfc/nfcmrvl/usb.c +++ b/drivers/nfc/nfcmrvl/usb.c | |||
@@ -305,6 +305,7 @@ static int nfcmrvl_probe(struct usb_interface *intf, | |||
305 | 305 | ||
306 | /* No configuration for USB */ | 306 | /* No configuration for USB */ |
307 | memset(&config, 0, sizeof(config)); | 307 | memset(&config, 0, sizeof(config)); |
308 | config.reset_n_io = -EINVAL; | ||
308 | 309 | ||
309 | nfc_info(&udev->dev, "intf %p id %p\n", intf, id); | 310 | nfc_info(&udev->dev, "intf %p id %p\n", intf, id); |
310 | 311 | ||