diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c index 36a5170b036..6fa61800431 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c @@ -1013,6 +1013,12 @@ static struct otto_l3_route *otto_l3_host_route_alloc(struct otto_l3_ctrl *ctrl, mutex_lock(ctrl->lock); idx = find_first_zero_bit(ctrl->host_route_use_bm, MAX_HOST_ROUTES); + if (idx >= MAX_HOST_ROUTES) { + dev_err(ctrl->dev, "host route table full, %d entries in use\n", + MAX_HOST_ROUTES); + mutex_unlock(ctrl->lock); + return NULL; + } dev_dbg(ctrl->dev, "id: %d, ip %pI4\n", idx, &ip); r = kzalloc(sizeof(*r), GFP_KERNEL); @@ -1057,6 +1063,12 @@ static struct otto_l3_route *otto_l3_route_alloc(struct otto_l3_ctrl *ctrl, u32 mutex_lock(ctrl->lock); idx = find_first_zero_bit(ctrl->route_use_bm, MAX_ROUTES); + if (idx >= MAX_ROUTES) { + dev_err(ctrl->dev, "prefix route table full, %d entries in use\n", + MAX_ROUTES); + mutex_unlock(ctrl->lock); + return NULL; + } dev_dbg(ctrl->dev, "id: %d, ip %pI4\n", idx, &ip); r = kzalloc(sizeof(*r), GFP_KERNEL);