crypto: msm: Add validation checks for memory cleanup

Add validation checks to handle memory freeing &
prevent NULL pointer access.

Change-Id: I6e82ea56754fb12b467d5ecb642411017c1e18c6
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>