From 6bdec2e32bab905d1c2a368ffb63a4bb80dc99fa Mon Sep 17 00:00:00 2001 From: Rey Tucker Date: Wed, 19 Dec 2018 19:28:43 -0500 Subject: [PATCH] host: libbladeRF: check for null rfic ptr in bladerf2_close Fixes segfault after flashing FPGA image --- .../libbladeRF/src/board/bladerf2/bladerf2.c | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c b/host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c index ab0e7182..d07e9be4 100644 --- a/host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c +++ b/host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c @@ -522,17 +522,19 @@ static void bladerf2_close(struct bladerf *dev) } } - if (board_data->rfic_reset_on_close) { - /* We need to fully de-initialize the RFIC, so it can be reset - * on the next open. This seems to be necessary after doing - * direct SPI control of the RFIC. - */ - rfic->deinitialize(dev); - } else { - /* Put the RFIC into standby mode. This will shut down any - * current RF activity, but it will not lose the RF state. - */ - rfic->standby(dev); + if (rfic != NULL) { + if (board_data->rfic_reset_on_close) { + /* We need to fully de-initialize the RFIC, so it can be + * reset on the next open. This seems to be necessary after + * doing direct SPI control of the RFIC. + */ + rfic->deinitialize(dev); + } else { + /* Put the RFIC into standby mode. This will shut down any + * current RF activity, but it will not lose the RF state. + */ + rfic->standby(dev); + } } free(board_data);