From: Luca Ceresoli Date: Mon, 11 May 2026 16:40:05 +0000 (+0200) Subject: drm/bridge: drm_bridge_put(): ignore ERR_PTR X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55bb2b137b6d72b3281f70045d9ee5a087df0aa4;p=thirdparty%2Fkernel%2Flinux.git drm/bridge: drm_bridge_put(): ignore ERR_PTR Most functions returning a struct drm_bridge pointer currently return a valid pointer or NULL, but this restricts their ability to return an error code as an ERR_PTR describing the error kind. In preparation to have new APIs that can return a struct drm_bridge pointer holding an ERR_PTR (and for those which already do) make drm_bridge_put() ignore ERR_PTR values, just like it ignores NULL pointers. This will avoid annoying error checking in many places and the risk of missing error checks. Suggested-by: Laurent Pinchart Link: https://lore.kernel.org/all/20260318152533.GA633439@killaraus.ideasonboard.com/ Suggested-by: Dmitry Baryshkov Link: https://lore.kernel.org/all/omlnswxukeqgnatzdvooaashgkfcacjevkvbkm6xt33itgua2k@jcmzll2w6kdq/ Reviewed-by: Dmitry Baryshkov Reviewed-by: Laurent Pinchart Link: https://patch.msgid.link/20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-1-f61c9e498b3f@bootlin.com Signed-off-by: Luca Ceresoli --- diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index ce180f0b26b23..b46c01db8d836 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -300,7 +300,7 @@ EXPORT_SYMBOL(drm_bridge_get); /** * drm_bridge_put - Release a bridge reference - * @bridge: DRM bridge; if NULL this function does nothing + * @bridge: DRM bridge; if NULL or an ERR_PTR this function does nothing * * This function decrements the bridge's reference count and frees the * object if the reference count drops to zero. @@ -310,7 +310,7 @@ EXPORT_SYMBOL(drm_bridge_get); */ void drm_bridge_put(struct drm_bridge *bridge) { - if (bridge) + if (!IS_ERR_OR_NULL(bridge)) kref_put(&bridge->refcount, __drm_bridge_free); } EXPORT_SYMBOL(drm_bridge_put);