drm_modeset_lock_all(fb_helper->dev);
        drm_client_for_each_modeset(modeset, &fb_helper->client) {
                crtc = modeset->crtc;
-               if (!crtc->funcs->gamma_set || !crtc->gamma_size)
-                       return -EINVAL;
+               if (!crtc->funcs->gamma_set || !crtc->gamma_size) {
+                       ret = -EINVAL;
+                       goto out;
+               }
 
-               if (cmap->start + cmap->len > crtc->gamma_size)
-                       return -EINVAL;
+               if (cmap->start + cmap->len > crtc->gamma_size) {
+                       ret = -EINVAL;
+                       goto out;
+               }
 
                r = crtc->gamma_store;
                g = r + crtc->gamma_size;
                ret = crtc->funcs->gamma_set(crtc, r, g, b,
                                             crtc->gamma_size, NULL);
                if (ret)
-                       return ret;
+                       goto out;
        }
+out:
        drm_modeset_unlock_all(fb_helper->dev);
 
        return ret;