From 17856620cf8a3bb1e4611bb2e219b14e2eec0761 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Fri, 29 Oct 2021 14:40:44 +0200 Subject: [PATCH] drivers: ieee802154_cc1200: Fix unchecked return value coverity issue Verify the return value of `gpio_add_callback()` call. CID: 240678 Fixes #39825 Signed-off-by: Robert Lubos --- drivers/ieee802154/ieee802154_cc1200.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/ieee802154/ieee802154_cc1200.c b/drivers/ieee802154/ieee802154_cc1200.c index 2ad0ba829cc..93214be8a7b 100644 --- a/drivers/ieee802154/ieee802154_cc1200.c +++ b/drivers/ieee802154/ieee802154_cc1200.c @@ -199,13 +199,18 @@ static void enable_gpio0_interrupt(const struct device *dev, bool enable) gpio_pin_interrupt_configure_dt(&cfg->interrupt, mode); } -static void setup_gpio_callback(const struct device *dev) +static int setup_gpio_callback(const struct device *dev) { const struct cc1200_config *cfg = dev->config; struct cc1200_context *cc1200 = dev->data; gpio_init_callback(&cc1200->rx_tx_cb, gpio0_int_handler, BIT(cfg->interrupt.pin)); - gpio_add_callback(cfg->interrupt.port, &cc1200->rx_tx_cb); + + if (gpio_add_callback(cfg->interrupt.port, &cc1200->rx_tx_cb) != 0) { + return -EIO; + } + + return 0; } /**************** @@ -713,7 +718,9 @@ static int power_on_and_setup(const struct device *dev) return -EIO; } - setup_gpio_callback(dev); + if (setup_gpio_callback(dev) != 0) { + return -EIO; + } return rf_calibrate(dev); }