Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1665303rdb; Tue, 20 Feb 2024 03:24:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVMyTc6/uiXtWwkv2jgqaPkZsG4VPY/l5v8n0ju4VHzw1TW2NAFBe/jlgBA1Uru+OXB44AZwCcjTO/HpCUau/W5eBo3kMQ8TxkqC1nczg== X-Google-Smtp-Source: AGHT+IEDokFuxjFG1bRyZR7LneHPxvZ8p3wqTitkiCOL7N7Rjq6WUuIfq1LuYLabNbBLsuonMdgi X-Received: by 2002:a05:6a00:1395:b0:6e4:6630:8155 with SMTP id t21-20020a056a00139500b006e466308155mr5471675pfg.20.1708428297665; Tue, 20 Feb 2024 03:24:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708428297; cv=pass; d=google.com; s=arc-20160816; b=j0YdhS/3ifsolBHYcI+F0mowr9v9lm0BbvXluFblBenObDgxksWU+v6XV3rZYgx0Si 6Ciul8l8J4NDvP41ehkn0ut8rWebY9K3nc3SLCHsO1mpKVKuyugFcr2ckDLlApCADNgb YjdC6lRvPHY7ulTVpAINAg6x/x04lxZ3PwidoMifFRR2rlWej4/ATmaFJji5lkD3tJ4J UotCL1iUZinzJJWD7qfh884eZG+fNOYyHkOpqqmX4w/O883Qmbw6jVYYnCqXSXB3Piak z3jVI/xsKUJsh9/4qtV2BxI2KQgYH6wHzMoiUeJYd+IGBOkrG1+3gNqqpAIbKkQJNrE+ o/Rw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:in-reply-to:from :content-language:subject:references:cc:to:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=v2j5mL21V6LXw4j8zLfEHMsmzcRL4mOiH4Jel0MBT2w=; fh=l9zPRtEw4eMnhhgaoa5VQ96b2BJ8sY2ZRxv5vvgIupk=; b=Rix1RxaMBEIRRIR0bmrQpSdMj9iqCE18atQWmBxKcPbGMbIO0zpsYuJ91vYu2jPCOY 7bTP5xHPHMLpmKvXFyGDOd9SenWD3C3o3iq1cUOVaG8pHUlk4s/axdJ3mYRPpC+iG48G /oqxeP+odf+SFxGFhaV8UIp9r05j5zIP+AbtVeLoLtzwaABvEMk3s6Ba6/tnnwpyvFRe HBshRJOlyg53ln9M9TV59Ay8vkXsu/GwfEI/2kboSA96dorqCq9Ak812tT7q6ucwH0JQ Xxn1QJZCLT7j1QYV0CYbc0/gqOH+TemXT/z0G9qzUnbeT6AEbADx7D3tPNVzm0QUOyrB DCGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=BLdU6PEu; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-72878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72878-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q81-20020a632a54000000b005dc4ce8d29fsi6067818pgq.818.2024.02.20.03.24.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 03:24:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=BLdU6PEu; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-72878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72878-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 815C2B21491 for ; Tue, 20 Feb 2024 11:11:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E643679ED; Tue, 20 Feb 2024 11:10:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="BLdU6PEu" Received: from mout.web.de (mout.web.de [212.227.17.12]) (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 BE6E165BD9; Tue, 20 Feb 2024 11:10:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708427448; cv=none; b=NC20K2+LOAkvQA4956UXuvDUepetV0srKbQYauKXLNyJC9B39+S7dchpwBjoIbXAci/712k0BDg8JXXZMq1DgV+aX8Y8lBKM10Ikg10ARq/32VnZXRuiXFBECzk5K9q1LN3Yef9/57NOEv2Tdx7pdj6BLEte6tnzQpw2KaWxkoE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708427448; c=relaxed/simple; bh=MpJcVGRKO8AWBDMnssLpCilOGC18nfaO9n9RoVZq7VQ=; h=Message-ID:Date:MIME-Version:To:Cc:References:Subject:From: In-Reply-To:Content-Type; b=cgEql6SejxSuarVPtVUuOgkRufbQN6a507YkaeJ8lXezjFlr7svcFkBdBz3qWTzuqaGVWbWS7+/v+feZy8pk/2hnT6DIs/yvNk3HUroEPA0MBPOYXe8NKG8J/7b30wcrbVLqjpvlyeZXhW0eOemNnDS+gZ7gv2b5s4DMRaV3QQ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=BLdU6PEu; arc=none smtp.client-ip=212.227.17.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1708427438; x=1709032238; i=markus.elfring@web.de; bh=MpJcVGRKO8AWBDMnssLpCilOGC18nfaO9n9RoVZq7VQ=; h=X-UI-Sender-Class:Date:To:Cc:References:Subject:From: In-Reply-To; b=BLdU6PEuy96My08QHX+sfAMRWW4IK1X4d0T4z7p4DxV7MRkglWrcZf/j/tZKdw52 YPMAa2l6FxXjQdxzj85XS/JNEH9oDG/yKaghQ2vCY2NfS1Kb49HmyUj+GrUD85WqQ 8RNDEIiRbmSjIwPbGf/sSU2rQRZhM51J48MM7HybPKuk1Wofxj67i5sJb8fCQZu0v W/79FPqhyfb5sz0FQ05r+Usub8KlNKiZYpi0CoK3MsPsiy0LZ+Q9NgLIEq6arb5/3 gu86okYONMl5QBxcn6SytaLQHWAyDAtkOmAFfD5zc4XMnhGSw7Qy4gsQb/CGAeWec m/95GOLhnMPpFIYZBQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.80.95]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1M7Nig-1rZ6Xk3SFY-007pjU; Tue, 20 Feb 2024 11:56:00 +0100 Message-ID: <9ff4221a-7083-4cb1-abde-1690f655da8d@web.de> Date: Tue, 20 Feb 2024 11:55:57 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Johan Hovold , freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-phy@lists.infradead.org, linux-arm-msm@vger.kernel.org, kernel-janitors@vger.kernel.org, Andrzej Hajda , Bjorn Andersson , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Neil Armstrong , Robert Foss , Thomas Zimmermann , Vinod Koul Cc: LKML , Abhinav Kumar , Dmitry Baryshkov , Jernej Skrabec , Jonas Karlman , Kishon Vijay Abraham I , Konrad Dybcio , Kuogee Hsieh , Laurent Pinchart , Rob Clark , stable@vger.kernel.org References: <20240217150228.5788-4-johan+linaro@kernel.org> Subject: Re: [PATCH 3/6] soc: qcom: pmic_glink_altmode: fix drm bridge use-after-free Content-Language: en-GB From: Markus Elfring In-Reply-To: <20240217150228.5788-4-johan+linaro@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:+nHgQKTeGuYog2KEpVvwroQxHKbVWgy4x84LyT/hTMOvc2YQpn3 JDDJBBZ8e8iXt3Iuyj6UFT2vAkr8MqMibV6zXbFxjjJ4NonyB3VINxG4cgtMo5Xs7xuC6zv xHHA+wCH+zFVfPWvJKoIfdB4zOgAfy83sRz8V39oAy7aiZgIKyhsi1FhkeElCu/itLaX0BA SMxSEIL5gaOlUNFNP274g== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:aOKHz1US+0c=;Y7LOb2uGXWAxALKRNeJNoMXdSED 6mThPuSgax6MusWH8Ux/RV+9w1zP98fwHF/F/EFha/52Eso2NCDEZICzFoaqBbjVZwC8X9iXj imqXDHI+XMO0+ZsKtOfqx24v88gE5o5vzibabRrgXDJNXGYIMVRv0FhA3zBLzLImf+0yKA0w3 JipXGp3SXIfH7L7HV9OeJp/lRlCX0T2dcB4emjiyAhry5gg7pglw5q81w+eBAmMASEC7p3QFl fNJMxuiOt8h2Rezr4SEiSyEQA6eYjV9YL2u7jd2D7a/Z782fqk3AH3QRs5XYKldiKIQ/ET21w kQy5vQRVco7VAXTQBMM4nu+jjOcrp7VwntKu1Lv8lSUeYMgoPk+03t1Jfd7Wq+v0DumL+b69s EFpggdlfcwjmUZiY1H5L0aypyi1fqDno1dcoD3BThjr7HInZntawd5DklobDax+czHsflIRKo EEald0kztZeVc20C//rszyjaE0lRLHAnbS1xEbuUhgIY6wQNfjOWsKpTlwmKkxJhg+G8V87Hw CsGHwCQpWo8JUQ2u8u13to8icfvbIURNZ/+0TOfimg6fk1e3Xp6tk5ZST+n0FupyGgbuzh8Xk /ckHy9ppsFBiMNkezud3jl9lRX5YB1WBEQYzDYOCWdxsFvo3mw715qMWQEMJjar3JQR4i/NFh wpz15f441+KtAxdh9D+nYKtO57bx/KSH6YPyS0OgfVYWQnCwWw9/FSkWuNj+8E9Xouf+xnsSV 7i9vSiZZCGaVCFmj7xKEWlGyBccfvDxkylTO9r0FdjfgxCZQFBHfYnKaMD47c7kVBC5lznyEq 1ZP+jYKEtNDnFoMJvSTvMXP1v6aJ26Z0pgxbocw6whsgI= =E2=80=A6 > Specifically, the dp-hpd bridge is currently registered before all > resources have been acquired which means that it can also be > deregistered on probe deferrals. > > In the meantime there is a race window where the new aux bridge driver > (or PHY driver previously) may have looked up the dp-hpd bridge and > stored a (non-reference-counted) pointer to the bridge which is about to > be deallocated. =E2=80=A6 > +++ b/drivers/soc/qcom/pmic_glink_altmode.c =E2=80=A6 > @@ -454,7 +454,7 @@ static int pmic_glink_altmode_probe(struct auxiliary= _device *adev, > alt_port->index =3D port; > INIT_WORK(&alt_port->work, pmic_glink_altmode_worker); > > - alt_port->bridge =3D drm_dp_hpd_bridge_register(dev, to_of_node(fwnod= e)); > + alt_port->bridge =3D devm_drm_dp_hpd_bridge_alloc(dev, to_of_node(fwn= ode)); > if (IS_ERR(alt_port->bridge)) { > fwnode_handle_put(fwnode); > return PTR_ERR(alt_port->bridge); =E2=80=A6 The function call =E2=80=9Cfwnode_handle_put(fwnode)=E2=80=9D is used in m= ultiple if branches. https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/soc/qcom/pmic_gli= nk_altmode.c#L435 I suggest to add a jump target so that a bit of exception handling can be better reused at the end of this function implementation. Regards, Markus