diff --git a/src/gcm-picker.c b/src/gcm-picker.c
index c97b665..142ebfe 100644
--- a/src/gcm-picker.c
+++ b/src/gcm-picker.c
@@ -267,7 +267,7 @@ gcm_picker_measure_cb (GtkWidget *widget, gpointer data)
 	if (!ret) {
 		g_warning ("failed to lock: %s", error->message);
 		g_error_free (error);
-		goto out;
+		goto out_nolock;
 	}
 
 	/* get color */
@@ -295,7 +295,8 @@ gcm_picker_measure_cb (GtkWidget *widget, gpointer data)
 		goto out;
 	}
 #endif
-
+out:
+        error = NULL;
 	/* unlock */
 	ret = cd_sensor_unlock_sync (sensor,
 				     NULL,
@@ -306,11 +307,12 @@ gcm_picker_measure_cb (GtkWidget *widget, gpointer data)
 		goto out;
 	}
 
-	gcm_picker_refresh_results ();
-	gcm_picker_got_results ();
-out:
-	if (tmp != NULL)
+	if (tmp != NULL) {
+	        gcm_picker_refresh_results ();
+	        gcm_picker_got_results ();
 		cd_color_xyz_free (tmp);
+	}
+out_nolock:
 	return;
 }
 
