Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp693620lqo; Fri, 10 May 2024 11:43:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+8fvap4v57oszTTCqu1+PnoKlMqAKUrPfUbIb+ztVh3SdkkQjo02yveyj1/5S99YWFkRroqlgPeIwv/9gvGexPT9fFRzFYJCjETgrjw== X-Google-Smtp-Source: AGHT+IGwuyFObDzDSxFkLR4aMRy5/Mv2fXZEmKm6xxZne1JuzHpS8KTjFDfiNrpoKwvm2V1FXLF4 X-Received: by 2002:a17:903:28d:b0:1eb:7746:4237 with SMTP id d9443c01a7336-1ef43d127f9mr47417995ad.19.1715366636287; Fri, 10 May 2024 11:43:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715366636; cv=pass; d=google.com; s=arc-20160816; b=VjC9peptde3bicz7uaMx+0EDuZm6aA3yVu6r0wFL9Nqswd0WTqrT1oDbnU3qnlKWAo a0VV4Vieci/WvNdWWLVAEFRp++m6lRVRAoBOUxkIyIwkELh3C54qQiCGi+xX5f+1z/g/ nVpBgJKITP52tVduwDW/WkU/EmdrdIck9k1K88keeT826MWXhbDkWrO8KgJqxNE2D63o U2ygZrBiojgiM6M8JM9FUofuxGuKw5/W0Ee5omMrss3lC15bUvY8pmxdHA95BemtF9ie TF1VrTRW/ZhZvkL7agbcEhc6rQsklEZNbWlxwHAdd7vz0Sw5j7vYJ/XvPOeNqwdSxj4P fPrw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=3leKVp6DbOZKt/BkP9hZjqxScIgMDd3b3vJx/j0Aby4=; fh=rE8EvLTRcHi5UD/jz20zWlhuHwqEoPoJzOuX4RlybC8=; b=ianZ+m0+q9+c13j6WLWEcElWmR3UY6jhh2mEzE+iGBb8ORZVIDvp6VWa9vnSMuwnFW fSBS/BLrhdTDWQ3QZpehwFsojB48h7h/RmkWnNoObfE1l8s78xvPWcftvNS/FhXIw6Te Leg9aS1bi9WmMuLNCVKejdnVTJljv3jru0Q2u7AHHKUKZRaLywXjpQKsZe/ornZ5gggS doxiX912iQ4XdPEkgrzJ/m9QfvxQGnOciBMkDA51tw/q31vp3h50vHsYTL1M4xdohPOp qePzBz4rOHAty1Z1cwpOhDxoAqJGbUPCapLtpoMf6BpeWfe17Wwwi038jvSA5PE1Gbfd UkoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EMaS2WYk; arc=pass (i=1 spf=pass spfdomain=flex--jthies.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-176114-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176114-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c15ba47si43667915ad.539.2024.05.10.11.43.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 11:43:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176114-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EMaS2WYk; arc=pass (i=1 spf=pass spfdomain=flex--jthies.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-176114-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176114-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DE8C428833D for ; Fri, 10 May 2024 18:43:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1D9245979; Fri, 10 May 2024 18:43:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EMaS2WYk" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6B3B3E48C for ; Fri, 10 May 2024 18:43:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715366620; cv=none; b=VamJIGp6h4HZ0if7+FMXkIyjW/1Nmo7mG1SgtT46CCOdtCF1MQVgxduBRl8vmzN/hyJ+VHoOG9YQw+DBhIWznYhMAJCjL9pEz5D92DN8u/8KhcKHE9kDAZLcQW/igyNtJXWp/jSVbHo/hnV6J8b8pOYnVkGidKaL102j7ewKcGY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715366620; c=relaxed/simple; bh=bPIwwSWz7vhLPkw2Y7IUkySooH/UFfl9RPgbQvpMT1Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=PGA50l/jsWK2yOwD+ScwBdWbwZYCWdE6eoboDdi38hQPtKeqCPoYV9CuGL6knzVOaG44LdjS7dOZauWX8mB/yQfBVnijlyVc0xqQkfwI5DR9iDNo7OqcqOoAsOjr1inQbQ9Q5wHCTkYols1NS3OHRBFtNgKkaSiKgqaMtmoUVUA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EMaS2WYk; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-61be8f7ed6eso27405747b3.0 for ; Fri, 10 May 2024 11:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715366618; x=1715971418; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=3leKVp6DbOZKt/BkP9hZjqxScIgMDd3b3vJx/j0Aby4=; b=EMaS2WYkbIhvSmYlF4THbt56fWrbxMNAFU61GNmmeRwGXAf3/nXb8b42DdQcWrE4+A CvD1v/fcygFSRp99Y31jGCzjTzO+iwU5piRu7jVfVHPAH4fsD1xCYMr8cVUgudkhBKyD Vv6avvdbT9eJm+BnZ08aI0X7HohEgF9RHWgvexzVUqjsyV6WtEAtzMyHP0T1E0dxKcra ARkBdnBqfZ+CGojc4ls3mLxrCkPuzBMLQfiEgbEHU0T3yIVJ+mDiDkWbHdidHJ8fQhJD V4RI7zvETjauRhFNaXIJLGKjOVBF7Pt4dehm4SKoI8vRspSHYSfF3lC1lU3FL79CRYsP L/9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715366618; x=1715971418; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3leKVp6DbOZKt/BkP9hZjqxScIgMDd3b3vJx/j0Aby4=; b=JkEdx5QtOn16qwkqWoE1QqhfIlYDfvEPk7h/6Qj3bMiH0Ijl9xe9aBYB1bOoJ/eKm8 sx7HwI2X/MTyg+gtAYQ7VXWbzPiYAbZA3kHz5DD5HquVzDnBoeqk5oMTEgTEdTBWP/v8 hAa5I9HeOTH9+ndK8yMGYgznWm7XBBkxCiRQUPJSLbIOqHVnBfohgiVietpCpzXLIT1q vwD7LI4cxK/kqwRxwTBeaf1iXeyPS0IhISKye8dvhKY+AxcDci2W1d1+fQjcjbUOmQLQ 4czgnTj5Wa5DD5WqaVWW0TOq8aJCEk5fgO4AyCttE3zyZ4RO6XmsfDpsThlPY6Uf0odR 7SyA== X-Forwarded-Encrypted: i=1; AJvYcCWBOvTRCZdbOhwN+45H8BahiUJQJ4N8DeiQeB2UkbiWlCuWKS87ZGwn+U17CPLQgKukANEjiGsGm2VzKTZnibxykxVJIGE1YS3MhhqP X-Gm-Message-State: AOJu0Yx6JC2zb2etoV3q5IIUJGjW0k246DuZ6jd/Psfzc84Fj9TYEQ3e oSewWuqmv9Xzm0hrV3RFsJxLKj4C7cjySKp1R84vmYJc/+scSQQ2euLXyBBAhpqasdY29DBVbiD Bgg== X-Received: from jthies.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:23db]) (user=jthies job=sendgmr) by 2002:a05:690c:6202:b0:611:5a9d:bb0e with SMTP id 00721157ae682-622af90c63bmr9600407b3.4.1715366617882; Fri, 10 May 2024 11:43:37 -0700 (PDT) Date: Fri, 10 May 2024 18:43:21 +0000 In-Reply-To: <20240510184324.2944101-1-jthies@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240510184324.2944101-1-jthies@google.com> X-Mailer: git-send-email 2.45.0.118.g7fe29c98d7-goog Message-ID: <20240510184324.2944101-2-jthies@google.com> Subject: [PATCH v4 1/4] usb: typec: ucsi: Fix null pointer dereference in trace From: Jameson Thies To: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org Cc: jthies@google.com, 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, Benson Leung Content-Type: text/plain; charset="UTF-8" From: Abhishek Pandit-Subedi ucsi_register_altmode checks IS_ERR for the alt pointer and treats NULL as valid. When CONFIG_TYPEC_DP_ALTMODE is not enabled, ucsi_register_displayport returns NULL which causes a NULL pointer dereference in trace. Rather than return NULL, call typec_port_register_altmode to register DisplayPort alternate mode as a non-controllable mode when CONFIG_TYPEC_DP_ALTMODE is not enabled. Reviewed-by: Benson Leung Reviewed-by: Heikki Krogerus Signed-off-by: Jameson Thies Signed-off-by: Abhishek Pandit-Subedi --- Changes in V4: - Updated commit message. Changes in V3: - Returns typec_port_register_altmode call from ucsi_register_displayport when CONFIG_TYPEC_DP_ALTMODE is not enabled. Updated commit message. Changes in V2: - Checks for error response from ucsi_register_displayport when registering DisplayPort alternate mode. 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..f66224a270bc6 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 typec_port_register_altmode(con->port, desc); } static inline void -- 2.45.0.118.g7fe29c98d7-goog