Check sehandle before fixing permissions

Change-Id: I73ba5519bf650f0c7f0a683f311099ff13747155