Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1620009lqt; Sun, 21 Apr 2024 02:37:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVnPkFSO8JFoyqQV5naRFjjyD5Lsp3jKu3Ge9j6Ivgp9wRUJlgqPwR4kUuXN8kllA+b52GWWNNajAKMbDWOcY3tNIHVrAWyr0u4Jt2FqA== X-Google-Smtp-Source: AGHT+IE/+cTtxHcWeGRmt1O1LztOtaTNRlVidHTXJu1OJgpBE0vbx4X7rw8O81WNh4F/9UMeILaZ X-Received: by 2002:a05:622a:142:b0:437:5fe8:ab34 with SMTP id v2-20020a05622a014200b004375fe8ab34mr8320611qtw.50.1713692258015; Sun, 21 Apr 2024 02:37:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713692257; cv=pass; d=google.com; s=arc-20160816; b=cQx6thx4TmiCMT2meveMWyFWcJuJ+VNN/SwTt2XymqiI/T07GALVKdyLovN99+T4hx y8VsVuX5/C56ZqwYVmyKH/nqu+TomaocT/IkByNE+YN8yyV8JjmQenx/g8vh8rYhoFMV O8Ifsir7mHBut6O+siObljlil01htrSBIik3tcDWJn9Vdv6zPPjDVPAqVNcQYwUxa8Xd gyHtJoXXOdd1N5cb4Jibo7DYz4syoerVw2Xfiuz64NgbCICh9C3CozrsNA0eIViUsXAu 5ak6e7SZ84HBYKAoyJ4ZA7hsFTbdqFCv5ybAzHnVs8ylGtgOucirMsmvZ6EJSLUjfpMr +59A== 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; bh=n+zc5zcBG/5XxDf0qYpAxwjig98N7rz4pYgW95NcuL4=; fh=a8tXgId8W1icZ5BxAaLaCqwRsz6gF3/9FUgBhapbYXw=; b=d/D7Pq4ZPIE/zSqRnwRQWCEaOqhX9KaU38RFsRX4pfIUA3+SmXpeBn5wB1rBR1fkDc V7PjxSf8MOpTcd0uQpil6njVxo2hTSkC7ApACD3gq8uQVthWlafJC780p+mnhRkLPw0+ QRWNTAPx9Xg0Cs+yyjxe0wlyYH7E7XjeV8HoF3r3gCqIV6B8pmxYHVT3/t3ffHFM9y61 U3j0rapR2eylh7fkyQjzMEfK+9+gdpV3fL7grjINbBjGrq8DQwngYr0itMoVP0pNHYVm MFuRwP7xyROD9HC8dgNXQSr2XjmN0n3HMzoEVjLKXvZk8u2WNH7Wp5KYiQwUh/9lkmQK XZ4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=c--e.de); spf=pass (google.com: domain of linux-kernel+bounces-152469-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152469-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ep16-20020a05622a549000b004374738a754si6814759qtb.553.2024.04.21.02.37.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 02:37:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152469-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; arc=pass (i=1 spf=pass spfdomain=c--e.de); spf=pass (google.com: domain of linux-kernel+bounces-152469-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152469-linux.lists.archive=gmail.com@vger.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 BA07A1C208B4 for ; Sun, 21 Apr 2024 09:37:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FB4B10A03; Sun, 21 Apr 2024 09:37:28 +0000 (UTC) Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1429C625; Sun, 21 Apr 2024 09:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.10.14.231 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713692248; cv=none; b=nRXqMLcUazcaHwkCieANqM0gR5VbcYKkLTEsatC780P0ji+NCnpfD4ysZG8K5Heyfw3fQQdF9m+q1jsDFBgBR53qw8DvGje2r87zU21+t+lCGDLtlZI2Es81Sy5jL5g0lkJVhVxomeJygo3NY7fJDbm/2Jt3hiF59xeNmW6Bf/w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713692248; c=relaxed/simple; bh=gRcDq0NrGX6/1/kSuxwyYx9WNXiEK2e2hJwS1DZI4W8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AqnG689eUA0qZwsuDfN0iNg6zJm5nuPzckzf7o0hE/LHYzUns07UWmJ42dZ0jVa05jjAX6wkZaxcCyk4WCl6rNHbLfBFDz4Jvvm/Zl4xnBF2r01XliudsecbcG0au8Ju2sbYu1dHnqlhfMI5DYlkM5kWibkbm7Yqc4Gm8uLvjYQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de; spf=pass smtp.mailfrom=c--e.de; arc=none smtp.client-ip=217.10.14.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c--e.de Received: by cae.in-ulm.de (Postfix, from userid 1000) id 715C014026B; Sun, 21 Apr 2024 11:30:17 +0200 (CEST) Date: Sun, 21 Apr 2024 11:30:17 +0200 From: "Christian A. Ehrhardt" To: Jameson Thies Cc: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org, pmalani@chromium.org, bleung@google.com, abhishekpandit@chromium.org, andersson@kernel.org, dmitry.baryshkov@linaro.org, fabrice.gasnier@foss.st.com, gregkh@linuxfoundation.org, hdegoede@redhat.com, neil.armstrong@linaro.org, rajaram.regupathy@intel.com, saranya.gopal@intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/4] usb: typec: ucsi: Fix null deref in trace Message-ID: References: <20240419211650.2657096-1-jthies@google.com> <20240419211650.2657096-2-jthies@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: <20240419211650.2657096-2-jthies@google.com> Hi Jameson, On Fri, Apr 19, 2024 at 09:16:47PM +0000, Jameson Thies wrote: > From: Abhishek Pandit-Subedi > > ucsi_register_altmode checks IS_ERR on returned pointer and treats > NULL as valid. This results in a null deref when > trace_ucsi_register_altmode is called. > > Signed-off-by: Abhishek Pandit-Subedi > --- > drivers/usb/typec/ucsi/ucsi.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h > index c4d103db9d0f8..c663dce0659ee 100644 > --- a/drivers/usb/typec/ucsi/ucsi.h > +++ b/drivers/usb/typec/ucsi/ucsi.h > @@ -496,7 +496,7 @@ ucsi_register_displayport(struct ucsi_connector *con, > bool override, int offset, > struct typec_altmode_desc *desc) > { > - return NULL; > + return ERR_PTR(-EOPNOTSUPP); > } Hm. This does not look correct to me. Ignoring trace the old code would have returned success if displayport is not compiled in and all altmodes (except for display port) would be registered. With your code ucsi_register_altmodes will always fail and abort altmode registration if it finds a displayport altmode and CONFIG_TYPEC_DP_ALTMODE is not set. I don't think this is what we want. Maybe it is better to guard the trace call with an if? Am I missing something? Best regards, Christian