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

Configure Feed

Select the types of activity you want to include in your feed.

drm/bridge: deprecate of_drm_find_bridge()

of_drm_find_bridge() does not increment the returned bridge
refcount. of_drm_find_and_get_bridge() is to be used as a replacement.

Suggested-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/dri-devel/20250319-stylish-lime-mongoose-0a18ad@houat/
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://patch.msgid.link/20251216-drm-bridge-alloc-getput-drm_of_find_bridge-v3-2-b5165fab8058@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

+18 -4
+18 -4
drivers/gpu/drm/drm_bridge.c
··· 361 361 * @bridge: bridge control structure 362 362 * 363 363 * Add the given bridge to the global list of bridges, where they can be 364 - * found by users via of_drm_find_bridge(). 364 + * found by users via of_drm_find_and_get_bridge(). 365 365 * 366 366 * The bridge to be added must have been allocated by 367 367 * devm_drm_bridge_alloc(). ··· 422 422 * @bridge: bridge control structure 423 423 * 424 424 * Remove the given bridge from the global list of registered bridges, so 425 - * it won't be found by users via of_drm_find_bridge(), and add it to the 426 - * lingering bridge list, to keep track of it until its allocated memory is 427 - * eventually freed. 425 + * it won't be found by users via of_drm_find_and_get_bridge(), and add it 426 + * to the lingering bridge list, to keep track of it until its allocated 427 + * memory is eventually freed. 428 428 */ 429 429 void drm_bridge_remove(struct drm_bridge *bridge) 430 430 { ··· 1509 1509 * the global bridge list 1510 1510 * 1511 1511 * @np: device node 1512 + * 1513 + * This function is deprecated. Convert to of_drm_find_and_get_bridge() 1514 + * instead for proper refcounting. 1515 + * 1516 + * The bridge returned by this function is not refcounted. This is 1517 + * dangerous because the bridge might be deallocated even before the caller 1518 + * has a chance to use it. To use this function you have to do one of: 1519 + * - get a reference with drm_bridge_get() as soon as possible to 1520 + * minimize the race window, and then drm_bridge_put() when no longer 1521 + * using the pointer 1522 + * - not call drm_bridge_get() or drm_bridge_put() at all, which used to 1523 + * be the correct practice before dynamic bridge lifetime was introduced 1524 + * - again, convert to of_drm_find_and_get_bridge(), which is the only safe 1525 + * thing to do 1512 1526 * 1513 1527 * RETURNS: 1514 1528 * drm_bridge control struct on success, NULL on failure