check_readonlyfs: free memory only when has been allocated

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>