Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E983EDEBF0 for ; Tue, 3 Mar 2026 21:29:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 48D7310E8DD; Tue, 3 Mar 2026 21:29:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=acm.org header.i=@acm.org header.b="E6KvA0WU"; dkim-atps=neutral Received: from 011.lax.mailroute.net (011.lax.mailroute.net [199.89.1.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id AD71510E8DD for ; Tue, 3 Mar 2026 21:29:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4fQTT738V1z1XM0pD; Tue, 3 Mar 2026 21:29:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:content-type:content-type:in-reply-to :content-language:references:from:from:subject:subject :user-agent:mime-version:date:date:message-id:received:received; s=mr01; t=1772573353; x=1775165354; bh=9ynOclQ3uytyJeDDhwGcswlJ Cmq2hElyOSKIspe/esU=; b=E6KvA0WUdsoA8QKAzHECiCTqJ6VT3Dd85gfwaF1M qiR5xBIiNCZkuk2Q+Yas+iuCPp2od/vjh5R3J5tQ/wEvcGqYI+FNqWunSfBcbXdc L0lGPHbn3xZHZ6kNlaqUaprvjbiKGmzbTztg2KlJWRu56nXp+cF41DsyrPKyOLSn CJsTeLru4SojqcExYg03MVjTnOD8Pofbok+1UeJUQEA874Mgt27HGdoct0bmsX0s q/HVtl3F+674rNAoarZVAVdPg3lW27ZywGPWNWGOdr8LUWtkg3wurHZ4tEsnn1ix h+7/+I+bKHYIwP77hlxeFi22X/iMGJUvgAqpujcBQoJGkA== X-Virus-Scanned: by MailRoute Received: from 011.lax.mailroute.net ([127.0.0.1]) by localhost (011.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id 7zSNimIb1FNe; Tue, 3 Mar 2026 21:29:13 +0000 (UTC) Received: from [192.168.132.187] (unknown [12.150.89.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 011.lax.mailroute.net (Postfix) with ESMTPSA id 4fQTT40prKz1XM0nm; Tue, 3 Mar 2026 21:29:11 +0000 (UTC) Message-ID: <618eb79a-3945-45b3-a7cf-7c073aa28039@acm.org> Date: Tue, 3 Mar 2026 15:29:10 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: __drm_fb_helper_initial_config_and_unlock() question From: Bart Van Assche To: Maarten Lankhorst Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann References: <7dcaf8d7-ed5d-4bfb-8c35-1e5f0dfbae56@acm.org> Content-Language: en-US In-Reply-To: <7dcaf8d7-ed5d-4bfb-8c35-1e5f0dfbae56@acm.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 3/3/26 3:15 PM, Bart Van Assche wrote: > The comment above __drm_fb_helper_initial_config_and_unlock() says > "Drops fb_helper->lock before returning". However, there is an > error path in that function that does not drop fb_helper->lock: >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 info =3D drm_fb_helper_allo= c_info(fb_helper); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(info)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 return PTR_ERR(info); >=20 > Is the code correct or is the comment correct? I don't think that > both can be correct. (+Thomas) Thomas, Does this untested patch make sense to you? Thanks, Bart. drm: Fix a locking bug in an error path Make sure that __drm_fb_helper_initial_config_and_unlock() unlocks fb_helper->lock. This has been detected by the Clang thread-safety analyzer. Fixes: 63c971af4036 ("drm/fb-helper: Allocate and release fb_info in=20 single place") Signed-off-by: Bart Van Assche diff --git a/drivers/gpu/drm/drm_fb_helper.c=20 b/drivers/gpu/drm/drm_fb_helper.c index 05803169bed5..16bfbfb0af16 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1641,8 +1641,10 @@ __drm_fb_helper_initial_config_and_unlock(struct=20 drm_fb_helper *fb_helper) drm_client_modeset_probe(&fb_helper->client, width, height); info =3D drm_fb_helper_alloc_info(fb_helper); - if (IS_ERR(info)) + if (IS_ERR(info)) { + mutex_unlock(&fb_helper->lock); return PTR_ERR(info); + } ret =3D drm_fb_helper_single_fb_probe(fb_helper); if (ret < 0) {