kernel: fix possible mtd NULL pointer dereference