scan-build:  fix nonull attribs passing NULL

Don't pass NULL values to syscalls which expect !NULL.
scan-build: fix bad free()

Don't free() values which are never created via malloc().