Fix potential null pointer dereference in bmx280_close

This commit is contained in:
PurpleCloudX 2024-11-25 22:43:58 +08:00
parent 744b34a9f3
commit 2dc752e074

@ -451,7 +451,7 @@ bmx280_t* bmx280_create_master(i2c_master_bus_handle_t bus_handle)
void bmx280_close(bmx280_t *bmx280) void bmx280_close(bmx280_t *bmx280)
{ {
#if CONFIG_USE_I2C_MASTER_DRIVER #if CONFIG_USE_I2C_MASTER_DRIVER
if(bmx280->i2c_dev!=NULL) if(bmx280 != NULL && bmx280->i2c_dev != NULL)
i2c_master_bus_rm_device(bmx280->i2c_dev); i2c_master_bus_rm_device(bmx280->i2c_dev);
#endif #endif
free(bmx280); free(bmx280);