Skip to content

Commit 87a8345

Browse files
committed
fix(periman): Return NULL if deinit callback is cleared
1 parent e8da66b commit 87a8345

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cores/esp32/esp32-hal-periman.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ bool perimanSetBusDeinit(peripheral_bus_type_t type, peripheral_bus_deinit_cb_t
236236
return true;
237237
}
238238

239+
// This no-op callback is used by perimanClearBusDeinit() to effectively disable bus deinit functionality
240+
// without setting the callback to NULL, which would cause errors in perimanSetPinBus() at line 146.
239241
static bool empty_bus_deinit_cb(void *bus) {
240242
return true;
241243
}
@@ -255,6 +257,9 @@ peripheral_bus_deinit_cb_t perimanGetBusDeinit(peripheral_bus_type_t type) {
255257
log_e("Invalid type: %s (%u)", perimanGetTypeName(type), (unsigned int)type);
256258
return NULL;
257259
}
260+
if (deinit_functions[type] == empty_bus_deinit_cb) {
261+
return NULL;
262+
}
258263
return deinit_functions[type];
259264
}
260265

0 commit comments

Comments
 (0)