From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796121784; b=TV0F643I8sjSLN9sN82rPnKlm3hnr2hlRCpuCRBc9m8ZajYUfl1khFwixs/vJ+J/xqnQ Prmg1QouCvpqgl0/aQFNMaMgEGgKhWDEz27wS+sULL48K4+GvfJAD7Wkf9JwSS6Bkrpe9 yx3dOPH9MSZ3R+zq6vtxijOXpeCLnSyBLN8PAZIFp9aJ+KHmvlXP3R7kd6k0xhzC5jKXo pOvo06OfEXg/YYRWEbnyCk1cTibBQMjk/f0LH9quZtYCblyolKJ7L1QxXI5xZ1AsGS9Sx wRULK1XzntVELvR5wWNatv/ppovlJe5xaKPGlbTjq2qrWY8Nn+yfmDdu8bouf2gABMA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796121784; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=PormgqfD+ZVoqYhCeRQVm5HR4y7J78021FVTb5JKMgQ=; b=aXOqeiDUu21R0AK2rq28BfJY0WXwm2K8iYTi9OTJ8HoEzYhKWzXk5wqjVPUBrdqFpEqn bEsgQexCDl6CDD/8HtxfRT73pdIYPfx1UZwz80JSZPN0y0ioFs102i/ddgAe1JYmvMeo/ yxk1u+ho3JJNar4zQ/amTCzkstSe40QxYmIcf9xP698yyd4bIJq0Q4LSe/i93PxcMFDC1 T08NoB29o3lkeJDTJR0xC6mbX1NoRRY99fDOs9Df85FsjCBBraFUt9jmiyAwJn6yC/Hmc sqOekcfpBKkMoSGJYSDQIw3T54A5cuL5q3L1uuupU6ZAcUUxOvmyXvK61RrocPIAoCA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=mPkTd9E1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A49F2606A31A; Tue, 1 Dec 2026 10:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=mPkTd9E1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FF2E1F00897; Tue, 1 Dec 2026 10:43:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796121784; bh=PormgqfD+ZVoqYhCeRQVm5HR4y7J78021FVTb5JKMgQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=mPkTd9E1Ee9UFvjokm8Jhz6L6wxWvogmyTwQnwfKhSZay7vZcSGdDwKda7v2JacxE TkFVonagIwXqAcD6A4BPRUi1m2gCLD6DTEq5a2tMbBvtP/bQWFwNEZdWtMuImU3MNs hN6eM+FTk9mAE2h54UWk6s3cPUPdbjbvX08EAfzE= Date: Tue, 1 Dec 2026 11:43:00 +0100 From: Greg Kroah-Hartman To: Heikki Krogerus Cc: linux-usb@vger.kernel.org, Alan Stern , linux-kernel@vger.kernel.org, Josef Bacik , stable Subject: Re: [PATCH 14/19] usb: typec: mux: it5205: fix oops on accessory modes Message-ID: <2026120141-eclipse-musty-9d40@gregkh> References: <20261027-llm-usb-v1-0-b9751ddb9c7c@linuxfoundation.org> <20261027-llm-usb-v1-14-b9751ddb9c7c@linuxfoundation.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Nov 06, 2026 at 03:54:07PM +0100, Heikki Krogerus wrote: > On Tue, Oct 27, 2026 at 03:57:54PM +0100, Greg Kroah-Hartman wrote: > > From: Josef Bacik > > > > typec_set_mode() passes a state without an alternate mode, and the USB > > and accessory modes (TYPEC_MODE_USB2 ... TYPEC_MODE_DEBUG) start at > > TYPEC_STATE_MODAL like the states of the alternate modes. TCPM and UCSI > > set TYPEC_MODE_AUDIO or TYPEC_MODE_DEBUG when such an accessory is > > attached. it5205_mux_set() then reads state->alt->svid: plugging in an > > analog audio adapter is a NULL pointer dereference. > > Please just explain here that the code is accessing state->alt->svid > without first checking does state->alt exist. > > Then make a note that state->alt is NULL if for example TCPM sets the > mux to an accessory mode TYPEC_MODE_AUDIO or TYPEC_MODE_DEBUG. Much better wording, thanks, I'll go make that change. > > The numbers must not reach the switch either: TYPEC_MODE_AUDIO has the > > value of TYPEC_DP_STATE_D. Without an alternate mode connect the > > SuperSpeed lanes for TYPEC_MODE_USB3 and disconnect them for the rest. > > I think what that is trying to say is that this driver needs to handle > the mode value separately with the "normal" USB Type-C modes and the > alternate modes, because those values overlap, right? > > > Fixes: 41fe9ea1696c ("usb: typec: mux: Add ITE IT5205 Alternate Mode Passive MUX driver") > > Cc: stable > > Cc: Heikki Krogerus > > Signed-off-by: Josef Bacik > > Signed-off-by: Greg Kroah-Hartman > > --- > > drivers/usb/typec/mux/it5205.c | 14 ++++++++++---- > > 1 file changed, 10 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/usb/typec/mux/it5205.c b/drivers/usb/typec/mux/it5205.c > > index 2ab2ba6a3cbd..00d5bd55e423 100644 > > --- a/drivers/usb/typec/mux/it5205.c > > +++ b/drivers/usb/typec/mux/it5205.c > > @@ -92,13 +92,19 @@ static int it5205_switch_set(struct typec_switch_dev *sw, enum typec_orientation > > static int it5205_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state) > > { > > struct it5205 *it = typec_mux_get_drvdata(mux); > > + unsigned long mode = state->mode; > > u8 val; > > > > - if (state->mode >= TYPEC_STATE_MODAL && > > - state->alt->svid != USB_TYPEC_DP_SID) > > - return -EINVAL; > > + if (mode >= TYPEC_STATE_MODAL) { > > + /* USB and accessory modes: not the DP pin assignments */ > > + if (!state->alt) > > + mode = mode == TYPEC_MODE_USB3 ? TYPEC_STATE_USB : > > + TYPEC_STATE_SAFE; > > So now if the mux is set to an accessory mode, this function returns > successfully, even thought the connector is not actually in that > accessory mode? > > Return -EINVAL in that case? Better idea, will go do that, makes the code simpler as well, thanks. greg k-h