Add appropriate checks to avoid NULL pointer dereferencing. Change-Id: I9b96eeb1cf3b860416c950b5c689dc5858e194c6 CRs-Fixed: 2300013