Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp29504lqp; Thu, 4 Apr 2024 06:24:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwXLTOnSlKGaEreOBzco4JmfgDkFq09HADkoJwvNHiPmOEtbbxkuefZYCYUXR90ovovjInJMaDlHPzmVpENI9sxctlgQEEuq3XKNAnLA== X-Google-Smtp-Source: AGHT+IGisN0GDC7tsiEe5sM5iS1B96HK2Ly0S+Q5A80i0fEHimZFuoDKkR8/a+UB/HJFEbGen2d8 X-Received: by 2002:a05:6871:5213:b0:221:8e01:4c6f with SMTP id ht19-20020a056871521300b002218e014c6fmr2617491oac.36.1712237049573; Thu, 04 Apr 2024 06:24:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712237049; cv=pass; d=google.com; s=arc-20160816; b=GFZi3VpacpPCDdCqysxfn4vyptM9iSeSlipDCadKnxj7o/I7G2lXp5Q9Spm3JO6kuf Qg/94Z0hW/NESwwEF0nkRXdx0lv3+MHS9kQv9T1IPaI9dFfsCN0eWVefXDhMlY3Ksiy1 0Er9Uu5caYfM25GeQL0OLpC78PzltNuLMv+Al6ZSI7w3dwkZlb81abgAmUK7dOfS437I z0GX8wsKZ9JkE4KBgHxreVRz/qpGcZyvOYBhCewbQCe+Hnq6J+byaK+gHAAXaJpnsnHu z03wEbCE310v42dv2v5EKdFkVR9eblPKCDCG29oHIqE4KonkNC5G6VRQ1SAED8kpph6U Fvhg== 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=9MYRuBoquQek7NOXmBKinkDgtVYslM0l9dlOM4SnSdU=; fh=CwapWOV+8bdGbdHOOYf8ZkOPMS5tPI/gpZoBtmAMuLs=; b=LsEktJEOimMgrg+fiy57elbFhhL36darCzcd3jUuUZgy5yRtbQ7x6JAvYzu0iZsqoo trU/19lmefTShw8exHxWHIvhxKVVMDsFYaFNka+MYXm97zh9yt2tIsL0v96qxiIQkdmq FIQJ6riKPG6baYXRnFFkkETIALZ0qxO/XRo+x1gv/leVGR5sOM5rnBdD4XTJuu+sYZBk 4u6ON1ivX9H/OmILuMObHuNzaojiLtYekETWG1LR42wu0xawTFUpA9MuCZdRQBOD2w26 n5LKVYoqDFhHp/K5k+xfmOdODEXZNag40hIQbddzhM7nGwhwiy7/QL87Gha6Q5mUGeJY sZaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sr3RWkXO; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-131499-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131499-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u11-20020a05620a120b00b0078d342fa71fsi4939876qkj.513.2024.04.04.06.24.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 06:24:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131499-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sr3RWkXO; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-131499-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131499-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.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 1F6AE1C261BD for ; Thu, 4 Apr 2024 13:23:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33BDE127B4E; Thu, 4 Apr 2024 13:22:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="sr3RWkXO" 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 45B6418AF6; Thu, 4 Apr 2024 13:22:38 +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=1712236959; cv=none; b=b7Fzu6k6Iy9B2DW24HVpCIUU6zW+9u+iDhQMPNq3CFkdsurj50Nef/mYM6aUOR4blwkQRmop+YnKONCyEpHYSXgOvlYUwkYhb9kRm0azm6TpDMZSKuyDLjbqYjm0LPWJRMkzO3X+Zl1iGlrL0iKY3ksmAmB014LoH8Idk4/hJ/Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712236959; c=relaxed/simple; bh=vJFS1OOOBDTIVLiOBBvr9XoF4wFwhB9JAXs15apE4q8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=usxOW9ZfBriQzAP5ZSCI38fyBuFlHd5ndyxMSqVAIlGzhoQZI3UuZ7bYJWRmnwU4ZMwiLbna2KApIaRRlCAPDtTgCvffHjkDnjqsLV24fn6oWHTypYxu6BWzYzytTfwjwX8j3Ok/6pLG5Q+YpIh5x5mJu2BZEvJ1u/KGj+eHlHo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sr3RWkXO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EC8DC433F1; Thu, 4 Apr 2024 13:22:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712236958; bh=vJFS1OOOBDTIVLiOBBvr9XoF4wFwhB9JAXs15apE4q8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sr3RWkXOhMotYSn9pOpI0QyDa5A606/aUsbPgOWx94TF7ptXcgT4nJidzNL7L0cmb 8FjS3+ALowu1kwAdrfTRhtD2LVv7ZZgj5Uf+5zseDG5q+ZoIcAJUojUyicohBWCqL7 U18QeojUpw5pwqUW6AjVEUuVSZ94Q70d9XTgK4CM= Date: Thu, 4 Apr 2024 15:22:35 +0200 From: Greg KH To: Kyle Tso Cc: linux@roeck-us.net, heikki.krogerus@linux.intel.com, badhri@google.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] usb: typec: tcpm: Correct the PDO counting in pd_set Message-ID: <2024040417-ice-decal-b37e@gregkh> References: <20240326151909.440275-1-kyletso@google.com> 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: <20240326151909.440275-1-kyletso@google.com> On Tue, Mar 26, 2024 at 11:19:09PM +0800, Kyle Tso wrote: > Off-by-one errors happen because nr_snk_pdo and nr_src_pdo are > incorrectly added one. The index of the loop is equal to the number of > PDOs to be updated when leaving the loop and it doesn't need to be added > one. > > When doing the power negotiation, TCPM relies on the "nr_snk_pdo" as > the size of the local sink PDO array to match the Source capabilities > of the partner port. If the off-by-one overflow occurs, a wrong RDO > might be sent and unexpected power transfer might happen such as over > voltage or over current (than expected). > > "nr_src_pdo" is used to set the Rp level when the port is in Source > role. It is also the array size of the local Source capabilities when > filling up the buffer which will be sent as the Source PDOs (such as > in Power Negotiation). If the off-by-one overflow occurs, a wrong Rp > level might be set and wrong Source PDOs will be sent to the partner > port. This could potentially cause over current or port resets. > > Fixes: cd099cde4ed2 ("usb: typec: tcpm: Support multiple capabilities") > Cc: stable@vger.kernel.org > Signed-off-by: Kyle Tso > --- > v1 -> v2: > - update the commit message (adding the problems this patch solves) > > drivers/usb/typec/tcpm/tcpm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) This fails to apply to my usb-linus branch :( Can you rebase and resend? thanks, greg k-h