[PATCH] lmb: add a check to prevent memory overrun