Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp314014lqt; Thu, 18 Apr 2024 16:41:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUAP47lNMhl98nFNex1UvO3FAQkDTI7ktod42ujGT9cHah+QJtwU3XBs+vp/CxL5WyPcHA3qLcYHOqcqIm4gfOwxuV8KjaMH3gQ4YB3QQ== X-Google-Smtp-Source: AGHT+IHqzHIo07Krpu8kargkW7S2E/qz86q1jBgtzJr/qZMdex41l3KYHk+TLQ3IXSx0t2LlTEEq X-Received: by 2002:a05:622a:22a6:b0:437:ca6d:1401 with SMTP id ay38-20020a05622a22a600b00437ca6d1401mr56064qtb.34.1713483680025; Thu, 18 Apr 2024 16:41:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713483680; cv=pass; d=google.com; s=arc-20160816; b=CVxWzBFBCV0AQp/1B3F8eG8/1/O3Wvyqgz0r87ucbQZH+p/S47wL9Rq5sKCVbLvitE xGfzUCwo5Rh2MmHqGGaJMXfez+3BwCHPQarGm7keepTWSmbEDKkon5W1vFMxaZA+lA/q Y8MgPNmhyB+hbtQY0Y/veki7llvRlfTLJxY/NDK1hT4N2bz85X1EYEP1PIOffmsCdx9Z BHlisAh+zPSFUKaIUsDtbQA/HiXouNzZE/ba2TY/iaRrhWdFXSJfJxURsuYZ930p9vOp WYbfG/68Aoq0+f7rFswJJq3PlcOlS7NxUVwPwRSTTqhDRn54s/ZqE2b3Bn7uE2tre3gV cagQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=KGXVJHkqXUXGowXRQlx5v2hqDJp91SY1761utJ4P5AQ=; fh=dUfR2BN4XVLprQfsmYGf3UMkDyS5sO7yFxSA9bUhUKY=; b=amXDJ2sfEZXHqc9jcChUFt6RxsjDjpk5bYjDflFstl63uwKUz0R0M8Ap+5k+bkf38P E8O2wDoYDuq1eJmLurTtOfvcBB2lZHSW566flBxK4fqAdnlqbbQsLkCFcD5srZ84QEp9 IBMkOUYRZDNszCSQVTiqMPXObwuTVEZBCgjhzrzXQr9z9zpZJ8/6TQZSHoZ35iZnhI17 +noa5ja010OCKt1bDJkA9dG5RA3iCS12CZhG+g14vvOw96y3jPDRXoK0Rmup3APDLvEm 7Ib9wZ/LHlweelPYgisnn4E5c4AiqlrNZXlMq3/9M13zO09pMWGf03zTPmogXWGZSeYg 7R/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UyXDSEpS; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-150865-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150865-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gd24-20020a05622a5c1800b00437a0c90c49si2804776qtb.663.2024.04.18.16.41.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 16:41:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150865-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UyXDSEpS; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-150865-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150865-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BF1791C20FFB for ; Thu, 18 Apr 2024 23:41:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9E1577F2D; Thu, 18 Apr 2024 23:41:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UyXDSEpS" Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 880616A025 for ; Thu, 18 Apr 2024 23:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713483672; cv=none; b=kZ6flndtaq+BD78oHMzQ2Te5CYlptMmWb21zfKXhoqt4bd+Hcqi2SJdIm27XJ27sxKtCtZ9+JEmzJxzfRRnP2DHI9lOJE7YOXBYe0FT70YbXaVclexpamUjpYUK18wO48QkD2zTURdnRZkxZUeiWAtBrMfUiCjjQnH555j8YwnY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713483672; c=relaxed/simple; bh=oS4EJBOFAK9U3IsQ2hlOiJf8LGZYq2pmuC4jtH1eYZQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TtZ85KqfiDsGisJUcOzWnUEa9a8iK030Sb4UXusxM3CD+apShMnE49cmLM/KfWccE4IKKUhsiLF/sUuHps+r+Ez0Xqs51oFimtOSdDr/CyNyBECicBk+PyxPmeGFGpPsYJPApIn6mPjG96jSH+O96V1Qmzm8VEp1HNZp5+jT2qY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=UyXDSEpS; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6f0aeee172dso447118b3a.1 for ; Thu, 18 Apr 2024 16:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713483671; x=1714088471; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=KGXVJHkqXUXGowXRQlx5v2hqDJp91SY1761utJ4P5AQ=; b=UyXDSEpSqJqSCCSRAl2GaHpDBNkxvH9trcGXi3/OH0yaxBRuswlMapSUeJ3JhCD7EM Cm3EDPMlbGvSrnRRLpqjOvfr9y0cuQyuNL5j1CfZJKucz1/btGJoRGDaWYK5L8cCWr8B AxpLcOqkt/2osDmRdb1cBo/gwWWGeKz7qNmghOtWbQMOrvQ7di7Mf/kDhebxJivQocdV qjTtd/6zR379lyi37KNB+HxSl3U+HgcDF0OXhsdCcdcSpvAceA3oNHQlLVf9W41LbfHT JYg4ZtMaieXfPLQ6q0CROJe9GzipCz2/2/0qgnQUU5IqwA9rPeSs4r4bOkwLXzjXCkXk 4ycw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713483671; x=1714088471; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KGXVJHkqXUXGowXRQlx5v2hqDJp91SY1761utJ4P5AQ=; b=fNQztgrV1GSjVvhoee2hWDtTtKox73Z+QKvz4KsiNl7lihWarX3AXBzM1QVYHz70Ur +ydT2mPh9z9n1cHY50lUnFBOKHc7YQiZaVMMG1xNmVvHYgOKX/onyWnfVUXOTsRt1L4Y /1voSvuNzmPFtx2FF5TmYgD95rKxXSmsqeBx5/Njxbt5WhVJ9l4fEBUkFcCKOKAdyjDT E8fgDNMDlLaA+bfRNI3wNUqiJB5qa2HNG8H0/KakBfhk2fOm5OaqzaXda0vJ7ZrNC60y 1x8fZgWT3eWoaj3xyfpxmar2PYwsTmB/iQ56otO2T3W5F5tlZVbP06mSavuyc4tXA1FD YD+w== X-Forwarded-Encrypted: i=1; AJvYcCU6vwZ6r2S17d0ZNaf2OpB7K/p8KHeu9wkJ5hRgUDyE723tvh8LlIIi6NN6QKlh7zitOhteK5o2pDYy836nkoyE3z6sPDAbM3weBLaT X-Gm-Message-State: AOJu0YzP5lLY7eyHEmPyJ1eojx9aaqnF/ghy1tRYFEFt23nX6Cx9lZ3g XqkclFD2TFa0SKpWQ/im0WKhxF1YUA4x4hYlencL00Z+0QGvxDShlHhDZVHJrTY= X-Received: by 2002:a05:6a00:2408:b0:6ed:416d:e9e with SMTP id z8-20020a056a00240800b006ed416d0e9emr867794pfh.16.1713483670741; Thu, 18 Apr 2024 16:41:10 -0700 (PDT) Received: from [172.20.10.110] ([209.37.221.130]) by smtp.gmail.com with ESMTPSA id ld2-20020a056a004f8200b006eaf43bbcb5sm2050444pfb.114.2024.04.18.16.41.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Apr 2024 16:41:10 -0700 (PDT) Message-ID: <15164074-f050-49ef-8e24-f64fc417a0b4@linaro.org> Date: Fri, 19 Apr 2024 00:41:08 +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 Subject: Re: [PATCH 1/2] usb: typec: qcom-pmic: fix use-after-free on late probe errors To: Johan Hovold , Heikki Krogerus Cc: Bjorn Andersson , Konrad Dybcio , Greg Kroah-Hartman , Dmitry Baryshkov , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20240418145730.4605-1-johan+linaro@kernel.org> <20240418145730.4605-2-johan+linaro@kernel.org> Content-Language: en-US From: Bryan O'Donoghue In-Reply-To: <20240418145730.4605-2-johan+linaro@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 18/04/2024 15:57, Johan Hovold wrote: > Make sure to stop and deregister the port in case of late probe errors > to avoid use-after-free issues when the underlying memory is released by > devres. > > Fixes: a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver") > Cc: stable@vger.kernel.org # 6.5 > Cc: Bryan O'Donoghue > Signed-off-by: Johan Hovold > --- > drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c > index e48412cdcb0f..d3958c061a97 100644 > --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c > +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c > @@ -104,14 +104,18 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) > > ret = tcpm->port_start(tcpm, tcpm->tcpm_port); > if (ret) > - goto fwnode_remove; > + goto port_unregister; > > ret = tcpm->pdphy_start(tcpm, tcpm->tcpm_port); > if (ret) > - goto fwnode_remove; > + goto port_stop; > > return 0; > > +port_stop: > + tcpm->port_stop(tcpm); > +port_unregister: > + tcpm_unregister_port(tcpm->tcpm_port); > fwnode_remove: > fwnode_remove_software_node(tcpm->tcpc.fwnode); > Reviewed-by: Bryan O'Donoghue