Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2302645lqt; Mon, 22 Apr 2024 07:17:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUu+fojVles16RxkXkc+WJLNUFWJgwR/O6DOtxH7Wgc3yMzlHZFlrUMepS5oH+8Sch/ubgq0OM//3HzjHCMyBhyGQKbDVkw0NZE1yHLxQ== X-Google-Smtp-Source: AGHT+IF8dHLotjfyTBvCuUrBq/tVId24rjPB9HewnQca5QdRYKoH6B41VgvRz8gs7vhlc4P3BxT8 X-Received: by 2002:a05:6a21:3409:b0:1ac:3b6e:3e4a with SMTP id yn9-20020a056a21340900b001ac3b6e3e4amr10168489pzb.9.1713795449885; Mon, 22 Apr 2024 07:17:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713795449; cv=pass; d=google.com; s=arc-20160816; b=rj0zKfcLQJR/UuDGT+sRNJvk+dV/cmDI6fo8aRlKHj9QShSwI9JJlXuuvR7T2EMpTH Y0iTsNZFoScKSo/0phuhKJi3guelJipAubnbptr1UIla9sM+h8D1z25oIBeSUFMGCf/i 3LR6GAx5QM8KSjyJkf6/EdJgNgpPdkmQKMCSxu/LJATmhUnkxUPq6LO7Ww0rmb8A7tFA yKaWu9NKeIfObG72ojWKIeWnfZcRTsNS6PsDu2rxF1TFfmAfzMGak1xKACdJWC7MvPjJ jCqRXVlWHKuXabZfjCczrJGjd/BUT/zrzG38px+yqq0OrFmz0ENxLflsH+V6aitiKKlZ 1tJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4XnO3FS3kJd1N7Zp9qIxduuoYmx49SdHZ++vG+z92es=; fh=K/NjJpBIHZrHKDdfiXuETXiB2DFK/EaRdFVVi9q/wJw=; b=zrOmOdEjHu3SmDydD/r1Cnr1Xzwuka406Uw50f5zIXyEXjNjbNVth7AbAWpgdVXQRM SORNSqmBilnyYK/24PpB0KXBtmib5eomb/6A7tLrUIaY5udP9XzljC7etiHEJeJbliux txFbWuFnmjOQum00SBa98pB5jr6GOnyl9ZX2TVlwgicmy+zGqhDhYsEoVpWMlRVbWQXI AVOM+MkDo8P3jmrlpeDMFtWFxuUus7lqEIrFkKXacyK/ydLzEO8pvjp4HdkG1x8iLTVN 6Hx4HCzTh/L1RjhSQwn6UmqepmmP2BVu4Qlp7Qz2YtbhFWwGPrC086MKQlxxNuoOSjo5 HDdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Sqkpgcbg; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-153272-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153272-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i22-20020a63cd16000000b005e840ae1398si7679217pgg.187.2024.04.22.07.17.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 07:17:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153272-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=@intel.com header.s=Intel header.b=Sqkpgcbg; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-153272-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153272-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 9BD74B249B4 for ; Mon, 22 Apr 2024 11:14:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9208914388E; Mon, 22 Apr 2024 11:14:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Sqkpgcbg" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 2D7BF145FEE; Mon, 22 Apr 2024 11:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713784440; cv=none; b=pI2GXDgNjTXQSGJphikB/yJvkMIslMSs/MOzl7bfJYlr6jgEDrRfVktLoLBPXImRdCtpoyltF/B0DUcwODDvmDUsuryGHan0A6csFnUJl/TklLcg/UC6rd1VxkuSFvcgH3BpkC0miiUzIPDg3HXMOoP/DowHpte0KQvML5PtkA0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713784440; c=relaxed/simple; bh=Zdgd6Fj5wUDm/hSh8fpDnEnjpUDlT+CuNtJ1yiPZDh8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R5LWHt4EkpkS0LyoO+bpVxNIFkV2tMksaN3iVrhwFL5rWkLw6WspRiPaEZgYqXGEoTtZXgvC/5uLZSHCIqlKLl7Mpz1KYl0ebDEwuOlHaxTRZjqpbvPRw6iXyd8eODjUPUg6wNgQIK5IqFPGica7ogiiY1MVcHtlS8FyIsxC/3c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Sqkpgcbg; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713784439; x=1745320439; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Zdgd6Fj5wUDm/hSh8fpDnEnjpUDlT+CuNtJ1yiPZDh8=; b=SqkpgcbgM3rpvAywqse7i02x6QveAKJ0E1JlzLFZxTfSXIVGCfS89sZp M6geA4fjdcTAdhdsfaDJRKFNckLjeLIr1/azKKyim5L+NlhedFYcdXghy JWLKcbIt3EtVaX7P1Q/i1qiy1XKsGem7smwB2bWHlTFBIbVYAc7hmXgzo gtOHtGhRhDt6c5ZA2Ccw9LG8BQ4HfoeUKfySemD8L6mrF1YbCSHhHbMN8 O7FsIWVg5ZTpPr3qLl0pdAfDV6YH9op6Kt0FJ/+ZJ8m/g/yYqf1Nk0Q55 /AVIsz3AF19+uZ9oKvV8yjp/VnZ9xMbYoMAqrF8ggUBMLw0wFsSuVdFvp w==; X-CSE-ConnectionGUID: F4kCHlZaTC+15N7YdWEXNA== X-CSE-MsgGUID: s+n5UrveSwG2/vIaR+0zlw== X-IronPort-AV: E=McAfee;i="6600,9927,11051"; a="19868743" X-IronPort-AV: E=Sophos;i="6.07,220,1708416000"; d="scan'208";a="19868743" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2024 04:13:58 -0700 X-CSE-ConnectionGUID: 59KrG3F5Svasv566kQDXJg== X-CSE-MsgGUID: jiOK+9VtQV+MSJDUnNQ9hg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,220,1708416000"; d="scan'208";a="28649184" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmviesa004.fm.intel.com with SMTP; 22 Apr 2024 04:13:55 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 22 Apr 2024 14:13:54 +0300 Date: Mon, 22 Apr 2024 14:13:54 +0300 From: Heikki Krogerus To: Johan Hovold Cc: Bryan O'Donoghue , 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 Subject: Re: [PATCH 1/2] usb: typec: qcom-pmic: fix use-after-free on late probe errors Message-ID: References: <20240418145730.4605-1-johan+linaro@kernel.org> <20240418145730.4605-2-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240418145730.4605-2-johan+linaro@kernel.org> On Thu, Apr 18, 2024 at 04:57:29PM +0200, 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 Reviewed-by: Heikki Krogerus > --- > 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 -- heikki