ksgen: fix crash if rules is not specified

Change-Id: I15958dbeabc4377f712b0b4873b7687f850336d0
(cherry picked from commit ced2b09ecdff22d59493ce30e191f32bcb38f5e7)