diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 40cda0037ea5..319fe204da3a 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3631,8 +3631,17 @@ static int spi_controller_id_alloc(struct spi_controller *ctlr, int start, int e mutex_lock(&board_lock); id = idr_alloc(&spi_controller_idr, ctlr, start, end, GFP_KERNEL); mutex_unlock(&board_lock); - if (WARN(id < 0, "couldn't get idr")) + + /* + * Modify the error handling path to only trigger a WARN when the failure + * is not due to an out-of-memory condition + */ + + if (id < 0) { + WARN(id != -ENOMEM, "couldn't get idr"); return id == -ENOSPC ? -EBUSY : id; + } + ctlr->bus_num = id; return 0; }