Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/auth: make drm_{set,drop}master_ioctl symmetrical

Currently the ret handling is all over the place - with two redundant
assignments and another one addressed earlier.

Use the exact same flow in both functions.

v2: straighten the code flow, instead of just removing the assignments

Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200530124640.4176323-2-emil.l.velikov@gmail.com

+7 -5
+7 -5
drivers/gpu/drm/drm_auth.c
··· 215 215 int drm_setmaster_ioctl(struct drm_device *dev, void *data, 216 216 struct drm_file *file_priv) 217 217 { 218 - int ret = 0; 218 + int ret; 219 219 220 220 mutex_lock(&dev->master_mutex); 221 221 ··· 272 272 if (ret) 273 273 goto out_unlock; 274 274 275 - ret = -EINVAL; 276 - if (!drm_is_current_master(file_priv)) 275 + if (!drm_is_current_master(file_priv)) { 276 + ret = -EINVAL; 277 277 goto out_unlock; 278 + } 278 279 279 - if (!dev->master) 280 + if (!dev->master) { 281 + ret = -EINVAL; 280 282 goto out_unlock; 283 + } 281 284 282 285 if (file_priv->master->lessor != NULL) { 283 286 DRM_DEBUG_LEASE("Attempt to drop lessee %d as master\n", file_priv->master->lessee_id); ··· 288 285 goto out_unlock; 289 286 } 290 287 291 - ret = 0; 292 288 drm_drop_master(dev, file_priv); 293 289 out_unlock: 294 290 mutex_unlock(&dev->master_mutex);