sysfs: fix use_after_free issue

CID 73379 (#1 of 1): Use after free (USE_AFTER_FREE)
31. deref_arg: Calling fclose dereferences freed pointer fp.
shmem: don't unmap a memrory region in restore_shmem_content()

This function doesn't allocate memory, so it should not release it.

CID 73380 (#1 of 1): Use after free (USE_AFTER_FREE)
14. deref_arg: Calling munmap dereferences freed pointer addr.
cgroups: fix use_after_free issue

list_for_each_entry_safe() should be used, you we are going to delete
something from a list.

CID 73383 (#1 of 1): Read from pointer after free (USE_AFTER_FREE)
4. deref_after_free: Dereferencing freed pointer prop.

Cc: Tycho Andersen <tycho.andersen@canonical.com>
restore: don't leak a transport socket

CID 73354 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable sock going out of scope leaks the handle