From nobody Thu Apr 2 22:23:04 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEA493DA7E3 for ; Tue, 24 Mar 2026 09:09:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774343349; cv=none; b=eGg/3crxeLwelLURGbZl7LUGqXMD9wfHRjuBTN3SfnPAzHOTJZFCRpwa/e/nf3BsPYPushTO1Z9TpaYkp/Hht13edni+RQ6BOLqzwLn3nil0omC5F+6tvA2OMYv+gDHo7ld3RxDgwdhAx5ubQ/flrzRdUrRHhWUdQCap4z99uXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774343349; c=relaxed/simple; bh=/+If3BWjAyMuoGzHbM9d0fryNmHNITNic82YOxtEFz4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=s60mDrgKpA4Lk9jUKQBx72N443EMrhhLClsgTMgQuUxfRzQyB/+8oTKSY7qxi567O1nXVTpzD3jOTeVQVcprH/LdNNRmD2nlfF5MSyoFl4yfjtXe/3arEIaE6M8WbUpjWZu6tmQuK4ogeznbCDTYNfGGPuG6/gpg2Xzraoic0FI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dU2AF34M; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dU2AF34M" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id F0ECBC58095; Tue, 24 Mar 2026 09:09:25 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B41F36011D; Tue, 24 Mar 2026 09:08:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B7A061045116C; Tue, 24 Mar 2026 10:08:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1774343337; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding; bh=zk2OpegAMJiCNxvll5oNlkpQYOrJ2hMu552NiCOVNiI=; b=dU2AF34M4EZmzQR4Bri8TqIm9Jf64bxTGNlyNwlZe4327aw83E19d+74+eaZONsU9maBhF rRw58bV9NPEDBhRnGHNxiaL+K2pjZw1ugLW4jXCIiKBWjVjxG6dGf6Xqk0Gaq26h65O0HA ZNkp+qcBokkOhguTtXj9n1c86Cn7EwQlHZjMrhchouML0Vc+Oo2OM0ewwRfVJTBYLY7rGy z+NTCGMHbZPFF7vt2ITPezwdmuR2Prr/kbj+5iJ4nPyGKt9JcIRigHKwoKwuIN6OCS+rIW aclnt7cuXzuvseeJOZWzMnKyU12EzQCXyqxFvY7DcCkqAtqV0Li3S4522HKgEw== From: Luca Ceresoli Date: Tue, 24 Mar 2026 10:08:49 +0100 Subject: [PATCH RESEND] drm/bridge: drm_bridge_get/put(): document NULL pointer behaviour Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260324-drm-bridge-alloc-getput-document-null-check-v1-1-fb0877c49d7e@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Liu Ying , Hui Pu , Ian Ray , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 drm_bridge_get and drm_bridge_put() do nothing when they are passed a NULL pointer, and they do so since their initial addition in commit 30d1b37d4c02 ("drm/bridge: add support for refcounting"). This allows simpler code in various places when using these functions. However it's not documented, so it's not clear whether it is part of the API "contract" or just a current implementation detail that might change in the future. There is no visible reason to remove this NULL check, so document it, making it part of the contract, letting users count on it. Signed-off-by: Luca Ceresoli Reviewed-by: Liu Ying --- Historical note: I thought this was documented from the beginning and realized it's not the case when someone proposed adding a 'if (bridge) drm_bridge_put(bridge)' to a driver [0]. Let's fix it now. [0] https://lore.kernel.org/lkml/DG0CHD0TAH9A.27UW4KKY2O9V7@bootlin.com/ --- drivers/gpu/drm/drm_bridge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 3b165a0d1e77..3108249a63cd 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -282,7 +282,7 @@ static void __drm_bridge_free(struct kref *kref) =20 /** * drm_bridge_get - Acquire a bridge reference - * @bridge: DRM bridge + * @bridge: DRM bridge; if NULL this function does nothing * * This function increments the bridge's refcount. * @@ -300,7 +300,7 @@ EXPORT_SYMBOL(drm_bridge_get); =20 /** * drm_bridge_put - Release a bridge reference - * @bridge: DRM bridge + * @bridge: DRM bridge; if NULL this function does nothing * * This function decrements the bridge's reference count and frees the * object if the reference count drops to zero. --- base-commit: a50007089e078a1b7a826559a02277b1601ee189 change-id: 20260129-drm-bridge-alloc-getput-document-null-check-a551e64b8fc1 Best regards, --=20 Luca Ceresoli