From patchwork Sat Jan 13 20:55:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13519078 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 80A6C168C6 for ; Sat, 13 Jan 2024 20:55:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LTOoEGoe" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2cceb5f0918so80051081fa.2 for ; Sat, 13 Jan 2024 12:55:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705179357; x=1705784157; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=tOILqGWdvQGyp5yG9dNVVWooYzSrEZenpOm6yeqSMyQ=; b=LTOoEGoeUIP0lX6KoZ3uLXJwFiPj3eWEuRNTAu2Ths6nMMhXC4w8CdqQw5HW7/FMIc 4Nc1ixf+NTyb3lGlQYtsYPKgUA4VsnuSJk1+tK/ZAoN2Fh7UznjOZmLDvSskWPnr2prn xVw3Iye1pNZWVD3saTSTRFi5ByHPIk9xB2e8Cr4pYy5gG8RxYRvRC1VUhXCoFWfSEQx4 UooM31F8tf+rjPj4YfVQ6ykOybxSOOdP2VLSSndfv8UdxWTyDM2R/75Isqv7wh+rfe3y a2E8ps0QeCPxL+XIIn59qa55Y0Ok/7y6PjVMS7/+ZCHLXfc+LaI0xIzpswGr0SPy4rei QgtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705179357; x=1705784157; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tOILqGWdvQGyp5yG9dNVVWooYzSrEZenpOm6yeqSMyQ=; b=huLmSsZIsCoXZpaLRSDUY7yjemph2TKFKLhfjmnzkJ8VbZOAahq1T81DtwM5tbrYcK lM70H+R69g5/6vP42PBoUFjs1jsSomJmcLFn4e6lPs/59krIWFY9wq/C8YehFaygk2Cc SrzXi2CfEkKotKdVdi4WD6XvWXJan4tmPeCX6RmUB298Vi9+HM7un8KD8oZRdrYHwFnz HScTD626EXfpe9fTKbGvuVuJkFjg59jtp6vtxRQPMqwE6TU/QrfMBJLzL6Zhzzf7P2/J /fo7r7NpIaAV/tlb92XsshnHZLXH0T/PYA6GUM25DT7x2lnyCoeIfwIEQ4MnFh7RSIi7 r2qw== X-Gm-Message-State: AOJu0YzrEwH4Knzi3Rn5CrAj8Wqjb99If6J/wi7qXeodjRYEnvjKpC3E 25o9Mcoyq5XYfeVtixjspDVuYjeWB7xqig== X-Google-Smtp-Source: AGHT+IGbBpFSRp/Rl6zlZ4fJ2bTh5KOLJ9A0MfJxpzIVB/9rSCLgY5y9Hre1H/aLuz0I9VnjnNeXdg== X-Received: by 2002:a05:6512:694:b0:50e:ac0e:ad95 with SMTP id t20-20020a056512069400b0050eac0ead95mr1258023lfe.15.1705179357738; Sat, 13 Jan 2024 12:55:57 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id p14-20020a056512328e00b0050e9355d7eesm919802lfe.103.2024.01.13.12.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jan 2024 12:55:57 -0800 (PST) From: Dmitry Baryshkov Date: Sat, 13 Jan 2024 22:55:48 +0200 Subject: [PATCH v2 05/15] usb: typec: tcpm: fix the PD disabled case Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240113-pmi632-typec-v2-5-182d9aa0a5b3@linaro.org> References: <20240113-pmi632-typec-v2-0-182d9aa0a5b3@linaro.org> In-Reply-To: <20240113-pmi632-typec-v2-0-182d9aa0a5b3@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Wesley Cheng , Bryan O'Donoghue , Greg Kroah-Hartman , Vinod Koul , Kishon Vijay Abraham I , Guenter Roeck , Heikki Krogerus , Philipp Zabel Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-phy@lists.infradead.org X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1623; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=th0VPhhVwgxzRi9BZeZWRGueot5zBad9lANgJUi6Tq0=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBlovjW6dxyBLqmgIkLKgBNIXZP2morYd4M6kKeF 0II/6WztImJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZaL41gAKCRCLPIo+Aiko 1XoOB/4qZ/5yHK3+7TdrBie0roUiq0G242K8R7XP22EtAdGvBmxWVzee55dJ3/+oHlrEWLpYiw2 DHiVF7OJ/T04vnoqHN8vU0dEEcLmyBFKnkDWphBp4QAdHmbTg0iT+Mwu+2K9Uk8NaUK9mLk5OEU gImtz0ysLNcFI5mqe1mW4WPgD6QE5lMnn3wkNHC2DRpC7t0C+wv/DnjZGqO830bXqSBuzt9fg3s XHHZ8VZGmKb1ZoZZM6+GEtCj3ZooFds2sPN481vkCGiaIpPvuBzQSNtK9VbNuUb+0GSPopAiGhi C6Rc3vDxLup3pyubKVLVMyfD7EOZ5A7a0r8t2zlaWsVdn5RP X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A If the PD is disabled for the port, port->pds will be left as NULL, which causes the following crash during caps intilisation. Fix the crash. Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 Call trace: tcpm_register_port+0xaec/0xc44 qcom_pmic_typec_probe+0x1a4/0x254 platform_probe+0x68/0xc0 really_probe+0x148/0x2ac __driver_probe_device+0x78/0x12c driver_probe_device+0xd8/0x160 Bluetooth: hci0: QCA Product ID :0x0000000a __device_attach_driver+0xb8/0x138 bus_for_each_drv+0x80/0xdc Bluetooth: hci0: QCA SOC Version :0x40020150 __device_attach+0x9c/0x188 device_initial_probe+0x14/0x20 bus_probe_device+0xac/0xb0 deferred_probe_work_func+0x8c/0xc8 process_one_work+0x1ec/0x51c worker_thread+0x1ec/0x3e4 kthread+0x120/0x124 ret_from_fork+0x10/0x20 Fixes: cd099cde4ed2 ("usb: typec: tcpm: Support multiple capabilities") Signed-off-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tcpm/tcpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 5945e3a2b0f7..a0978ed1a257 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -6848,7 +6848,8 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) if (err) goto out_role_sw_put; - port->typec_caps.pd = port->pds[0]; + if (port->pds) + port->typec_caps.pd = port->pds[0]; port->typec_port = typec_register_port(port->dev, &port->typec_caps); if (IS_ERR(port->typec_port)) {