fix potential null pointer dereference.
I used fault injection to test the software and built memory faults, then i got some coredumps, mostly null pointer dereferences due to insufficient memory, so I check null pointer where possible problems occurred.
Signed-off-by: wangzhiqiang wangzhiqiang95@huawei.com