I should have written that in my first reply, but s == NULL means the given line number couldn't be found in the list of lines. This is a serious error and should be warned about. So maybe something like:
if (WARN_ON(!s)) return;
But allocating a new empty line in that case is certainly wrong.
Thank you, i have resend a v3 patch as you suggested.
-- Xiaomeng Tong