Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp40621lqt; Thu, 18 Apr 2024 07:59:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+JY8w3noVdLSgKjgJTluthzEEy9wuouUPrCOFitgGuRzbjERrZGQ5iZkSQsUxk7iw6bu+hV69XMV+1QheftbobZ3Y1439Wr/qaYKk9A== X-Google-Smtp-Source: AGHT+IEtUZWIUy4n0phZMLpH0Wm3WU1834E7BTIY+yiyH+LC81Y8tHIaGsRxKfOCSgZwgNeqMbgV X-Received: by 2002:ac8:5ace:0:b0:437:36df:e8ac with SMTP id d14-20020ac85ace000000b0043736dfe8acmr3344701qtd.9.1713452389785; Thu, 18 Apr 2024 07:59:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713452389; cv=pass; d=google.com; s=arc-20160816; b=sD48Aehh4FebBO89C8ZW8s8ExLBmoPsRBGFVHpnFuwG6T/YhTgFjLcaDpn7eDfUQea ZUU6kSiiJ/iB8+ejKsYwXoUAOCzPwamNheObidOP5IGl3vhNCe9yFnYeu8fm2oN4K3C3 yJIOw8sdr7vI2eeSjbAHl4YTL//SxXXT8TzLsYfu0oT2Lzf00GBm7nivw7ejpLslG7At 0bC0TpSAbc/6VDPWTIwRLPprP+tf9Fwv1TTTNNoq0SrnPSCxr/zwVcrkKXrt8DUMhsnT uf3gpUkkOJClaJvcrCfg5PgW0ex28VcZaPWUevnJ/krMHcXoyjWEihVjSODS+aOgqnS7 r7bw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7arAeV8hS1k27+eioHwmcB4m2ZYrReq34ZgL9IS3qXU=; fh=gkWOQ2HKdh+RYrlvY0RzYs7Jto1dxx+rFoAgb3bv5l4=; b=wa7QomQNusGLcI1J8wOl4PnUdIQnq8lirChwlozFY/y3GFd+lSnKkzdrX8hIU/dmQj fZYAz0paKDScXlO/ZE9NXJQsLJPQpnXSXW/wlT/Hra/WnqQGdqavjA2/s6yCU/Es+PvT duI4lDlyDZeLV8Zik7lBJXWlBsb91IKomlITkF/0zG9/dobXpSJWVbcTYh7Solw8SK9t GNT2B0HLilQJ9+37XGDtegQC+bD+qoS+bBeEMgnqC+bNZiHqsafguzVMb35EamXmyNWA Lqf0tTTrVSQ2AUHy1jyvw/k7nokclgrXvAdHJZim7Pl0PogWpj8SrjET+67t06UAoUQw HzOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dn9CNOmA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-150356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150356-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 cz2-20020a05620a36c200b0078d5e8ed907si1616766qkb.44.2024.04.18.07.59.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 07:59:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150356-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=@kernel.org header.s=k20201202 header.b=Dn9CNOmA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-150356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150356-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 830341C20BC9 for ; Thu, 18 Apr 2024 14:59:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F00916F8E3; Thu, 18 Apr 2024 14:58:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dn9CNOmA" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6F08A16C44E; Thu, 18 Apr 2024 14:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713452292; cv=none; b=HbnHvkXEgHaXaECNBFqB6bMHFSACJhLc/i1bqMaui+5zMOYrN7l1NtZ1QK4meHZad0jCg6Iskfc2/LYB0R+sC9wzB6wSEU3txVRbxzevTv/IVRFd96Jxbo8WEdzqPqsmxUsHOm7pYKZM8KVikHxMoZwiIOnPKzdq2TEEfaeZlT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713452292; c=relaxed/simple; bh=UK8vqYDQnVb4UuEiWOQ7/t28ga5C7zQ4CaigIsh4k3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ayoeMhg9TC0O1DBYGedMdjcNivRaax4H7TBHdYu5PR0dWubVdOS3Mkb1fspACFGv8AkhrkAY5pI968y7jFTrQF2chU4V0An1hyhXpVG9wQTLxM6BL16+hD4QNoYRUzddnR3UjQlXReeMNEbuyJ1uS8xlriRpzKVcQ3mOu15/OhE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dn9CNOmA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E47CC3277B; Thu, 18 Apr 2024 14:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713452292; bh=UK8vqYDQnVb4UuEiWOQ7/t28ga5C7zQ4CaigIsh4k3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dn9CNOmAuEatBytm3HjuegWQ0hIru7pceldtn92AnbKt2+bU2CWWXMS58cDbEstNa 9NQmyobuAmOc6OGSdMulV7gOBVmdhtUVJbraIF4tlLIlRFOD4xDuRije705U/Vn0an t9LEzzXyVmHgdbjVkEhYLl5Y3S2dXHfTEb8X1mzBbiTfoMgoBFjkSvCPy67vnhQlZU QiIhMH+X/MFz+gvBiBpGEVwzOKflLtkw4R8VMqqgVMqhi5Xiww2kCdzVGkq6I3W59r c2MVgh53JAle7ZUoOyQkZbWxw7dgXsVImfnJEmwy7tZffSev2kF5QJ/iOpAY+FyIbv xG8RM5UA+V5qQ== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rxTDK-000000001DR-2XFV; Thu, 18 Apr 2024 16:58:14 +0200 From: Johan Hovold To: Bryan O'Donoghue , 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, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 1/2] usb: typec: qcom-pmic: fix use-after-free on late probe errors Date: Thu, 18 Apr 2024 16:57:29 +0200 Message-ID: <20240418145730.4605-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240418145730.4605-1-johan+linaro@kernel.org> References: <20240418145730.4605-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.43.2