From nobody Mon Nov 25 02:56:47 2024 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2124.outbound.protection.outlook.com [40.107.117.124]) (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 72FDA1401B; Wed, 30 Oct 2024 13:37:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.124 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730295427; cv=fail; b=DgQfabX0Q+VvHg6Rnm9drYYBSFRDgkPh7D9afHhOjI+HUd20Gon3I79xNv9CMJzpHtmDyP7R2kEZYQ1tJLHsO2zcEiWbyAphv+oReS7Ystb8X97Dw0d8d9YRnApWjQZCPp9EHh9VtmD2KMp6jzvMMs0S5t8FezJxkbzAYwPt4RA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730295427; c=relaxed/simple; bh=O/iGRSAorpNwBkDgyIJvjzOaGMMND+sB5MhyqzW5C50=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Q+vyWuGpLAgw8BudwaPM9Mo+X1K1z2iXBUHrpfOmH1x5sAhyElWdMBDxJ1ewKOhsOca+t+MC8PYzRLfh8NKL1TZnBSmrMZTLRvETMaXadEPnX2XSYKg00Q9pyKuPgAo/WOpi523wTOatZnRAf7AsrRLkqAh7GZTfOgOLqwjcUuk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=jaguarmicro.com; spf=pass smtp.mailfrom=jaguarmicro.com; dkim=pass (2048-bit key) header.d=jaguarmicro.com header.i=@jaguarmicro.com header.b=HPrsMECi; arc=fail smtp.client-ip=40.107.117.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=jaguarmicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=jaguarmicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=jaguarmicro.com header.i=@jaguarmicro.com header.b="HPrsMECi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b3wVMtmYFdiYJLnK6JD+jCDwmZrSfkwl4n3Zozmuwc1D6uOnSaJ3Ou8q07Fr3VIo530gBr4QvN5KxsV8Icu740RmA0fXJydXCMeRlapEnPgqvaxpjY7utaH78+IkmOjU8zKqdR8USb6bXf6avbarnduHBiZyTpYfM6P9juRWtbKD19aZco+Phvz8wMaEuhAQp7qrFfvMdDcXRs6UW9N4AicQYlfxRiIVsbu7TENGmkGNAS1cGbESAZxfT17TseEQ1GLQU8/h2HucKS/yQB4ysRV3uxhoJdHripXwlaTuJo8kya0Aq0JrH00PbbbqmE1p7+HmqbNXWNsM/ARcHls0wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UGdU6oCVtdAIYbFXngWI0o7XjMRw4Fe7RE6DymhTqOI=; b=BUxq043fhUt2WbHfAX94EfO7rOtv7V8fTauSnSWl7+TIuc5n6pLmMcaP4DcorETYQFEMcGIZL5VHjYrKjcSuiRytYPFwfVN12BBU3Ebevo+xrvcLGV90qsV3aofUQxDvgEzKiiZNukMUYJD6GF0AWXJ2z45mj/aEEh9+3YysaJTJ/FKLZFkHnnUi8RNLmT/SybHnKQubcLGReglnPigd9ca09x4RoIwxOAbDyF90WCwTC2//gKNWfHPzz3fputiuzoh3752gV8xOf+ZYVX2MWxsHjsjyO6TsU9unuulpN3hhFipCwUepoIe/Rno6JKJEDu0AUKWnZYe2N6mEQfpdBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=jaguarmicro.com; dmarc=pass action=none header.from=jaguarmicro.com; dkim=pass header.d=jaguarmicro.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jaguarmicro.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UGdU6oCVtdAIYbFXngWI0o7XjMRw4Fe7RE6DymhTqOI=; b=HPrsMECifgNBbcb7Ovol/s8jcm2pKO4ZT0JngJU/hEh2+cPSKEmZvr99lbXiIvBVbmVPUn8EeR812fv/rVHAZ2nBK8mQwn4wa/gtrVvNpC/dp6pFXfqvD+X3k+aq32CGiSpumHPdGbA6H8bID9jGkLlhqV5pWFG+9FfXihyVK4iuuRJnUtBHy6sX7zaSH3EALb3la1GZvSkwvkpyGta5Omf/Vm0KMsLrY81V5hgvQDDgzolmvgnmo+XEzTyP0JjmfGUWkuB3LpgEqtwuuGZiao3ATiFbV/WOYFd3D5s6pGq/uVeTnOK4xRBqY8Kgm9m141xr/P6x6jzD36pd6N6uEg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=jaguarmicro.com; Received: from KL1PR0601MB5773.apcprd06.prod.outlook.com (2603:1096:820:b1::13) by SEZPR06MB6350.apcprd06.prod.outlook.com (2603:1096:101:133::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.13; Wed, 30 Oct 2024 13:36:57 +0000 Received: from KL1PR0601MB5773.apcprd06.prod.outlook.com ([fe80::b56a:3ef:aa9d:c82]) by KL1PR0601MB5773.apcprd06.prod.outlook.com ([fe80::b56a:3ef:aa9d:c82%4]) with mapi id 15.20.8114.015; Wed, 30 Oct 2024 13:36:56 +0000 From: Rex Nie To: bryan.odonoghue@linaro.org, heikki.krogerus@linux.intel.com Cc: gregkh@linuxfoundation.org, linux@roeck-us.net, caleb.connolly@linaro.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, angus.chen@jaguarmicro.com, stable@vger.kernel.org, Rex Nie Subject: [PATCH v4] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier Date: Wed, 30 Oct 2024 21:36:32 +0800 Message-Id: <20241030133632.2116-1-rex.nie@jaguarmicro.com> X-Mailer: git-send-email 2.39.0.windows.2 In-Reply-To: <20241030022753.2045-1-rex.nie@jaguarmicro.com> References: <20241030022753.2045-1-rex.nie@jaguarmicro.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TYAPR04CA0011.apcprd04.prod.outlook.com (2603:1096:404:15::23) To KL1PR0601MB5773.apcprd06.prod.outlook.com (2603:1096:820:b1::13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR0601MB5773:EE_|SEZPR06MB6350:EE_ X-MS-Office365-Filtering-Correlation-Id: d2a8d93c-a8e0-47e7-1b42-08dcf8e7ec34 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GL0Sqr98YVCeC9VrDZ7L2x89wXlLHI+azPi57UruYwrN2yjPDyliPfbWYZUT?= =?us-ascii?Q?BGxWeOJbRJha4JFSIbta4Xloef22MooE7HYfmvl146A7wADgwuLCW4omprSm?= =?us-ascii?Q?kOmjZdH+y2X7mTHVFmtMKrkk6pKKaH1woE8au3q0jGkzjdH6b2EfmkQ8/4r4?= =?us-ascii?Q?tgsUfrye8T8udDjnquXO74cTVm+AWJt11X68r4oQ1e8LmE8cauxlIXteHMt2?= =?us-ascii?Q?kl00xnB99Qv8OEjisp0hiwmCja6+Z/HcWfQYldU9gNXDYpwQWFzNLRALFspg?= =?us-asc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7lTig?= =?us-ascii?Q?rpfrXOXsMryBao2NTAZbgGCMR2htmWjgVmYlbKUJJYYchKxDyrrPF04uDkwL?= =?us-ascii?Q?N1Z4MORoDYX0hIpYzl8asiPdENeXTM4fSBS/8kffNO1sA98Phi8sL9Uy/CFs?= =?us-ascii?Q?Q7AWZi5AWrp2jNwNU7xNMq/zzCx4KURdihCwLCH6Hvj0phFpiPz54Zvj3fXL?= =?us-ascii?Q?Dj99juU6BdRh3lWgLsM9uThqf8IR?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:KL1PR0601MB5773.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?KFHsE9+dFxIofzvC7tm17VuWU4Faw22lEZf5Ge+YIP1IbtQ6vYrUfvMmL+N6?= =?us-ascii?Q?hjSpJio65h6yKh1x+xnXYovJU6QvvTNU/q/yx0ckaYIdhaslBUFwrBZtP9aC?= =?us-ascii?Q?2ijt60Z3BqnIW8T/NQ1Pe9WC+UTHjnVJRR+dUuaD2o9lgY1kqA5YOsB+GHDd?= =?us-ascii?Q?n2Hh6NtVb0d1wI9POsgA/QhHvSQ4uB6DZXQBxpNE4oIiVcwdKGzkE2EUU/Jx?= =?us-ascii?Q?8QaEEx5nNnRyz78hlAEebfT9k0GUvq1EoO9LuDCqJ7j4oHbW2E6tzDnsaZ+j?= =?us-ascii?Q?P+r+sXyVIz814FvY/zUGmqD2+2WxJd11ah686/C3MF2vxRfGElqZYPrXEsFB?= =?us-ascii?Q?Kfd41OclCPhEOqkfx7UbJCEJ3xlcEB1xyDAOUXZrRqScJ1nY2HJi8S8dPB/l?= =?us-ascii?Q?QdjABP+HgJIaW7wSKbKi8z+ABMqcq8kMPqWyZZblCd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hHhdT8VM4niP8/VU7gzc78T6iIsJJnPTF/PbJ2EfvWlyuSLU6dxp?= =?us-ascii?Q?QMaLoXcMAM3FJd5EEeGsMvA8Kkqwot0wwA5TyaLwFT+WeCBa2HtF6Te4WCZO?= =?us-ascii?Q?JypvbuWOxctZDWVCfPjW4MRzbTKYqWVU+x/7Qbt9beFDY9g9hZR12rCoesu9?= =?us-ascii?Q?dx68Ih57bC67aFNx8HOmug0IiDFMTUQYCdmrfq1I5CWfZqywLFhUQ8QW5dHO?= =?us-ascii?Q?bZoNBequwA0zFq9lsCaJyqTDYRZgb+/keoz/62Rg7OkqYjJQQkoM9cNLdk5X?= =?us-ascii?Q?MQ=3D=3D?= X-OriginatorOrg: jaguarmicro.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2a8d93c-a8e0-47e7-1b42-08dcf8e7ec34 X-MS-Exchange-CrossTenant-AuthSource: KL1PR0601MB5773.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 13:36:56.6016 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 1e45a5c2-d3e1-46b3-a0e6-c5ebf6d8ba7b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4V48+ydHfxUpYxtUNxKrNxsFmgOUS7yaxHf6nZBfBOyOxzR6VW5Wykx/6xj4q8j05OaX+Y0GoQ65lwEmFdjs6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB6350 Content-Type: text/plain; charset="utf-8" If the read of USB_PDPHY_RX_ACKNOWLEDGE_REG failed, then hdr_len and txbuf_len are uninitialized. This commit stops to print uninitialized value and misleading/false data. Cc: stable@vger.kernel.org Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC Type-C driver") Signed-off-by: Rex Nie Reviewed-by: Bjorn Andersson Reviewed-by: Heikki Krogerus --- V2 -> V3: - add changelog, add Fixes tag, add Cc stable ml. Thanks heikki - Link to v2: https://lore.kernel.org/all/20241030022753.2045-1-rex.nie@jag= uarmicro.com/ V1 -> V2: - keep printout when data didn't transmit, thanks Bjorn, bod, greg k-h - Links: https://lore.kernel.org/all/b177e736-e640-47ed-9f1e-ee65971dfc9c@l= inaro.org/ --- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/= usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c index 5b7f52b74a40..726423684bae 100644 --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c @@ -227,6 +227,10 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_= typec_pdphy *pmic_typec_pd =20 spin_lock_irqsave(&pmic_typec_pdphy->lock, flags); =20 + hdr_len =3D sizeof(msg->header); + txbuf_len =3D pd_header_cnt_le(msg->header) * 4; + txsize_len =3D hdr_len + txbuf_len - 1; + ret =3D regmap_read(pmic_typec_pdphy->regmap, pmic_typec_pdphy->base + USB_PDPHY_RX_ACKNOWLEDGE_REG, &val); @@ -244,10 +248,6 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_= typec_pdphy *pmic_typec_pd if (ret) goto done; =20 - hdr_len =3D sizeof(msg->header); - txbuf_len =3D pd_header_cnt_le(msg->header) * 4; - txsize_len =3D hdr_len + txbuf_len - 1; - /* Write message header sizeof(u16) to USB_PDPHY_TX_BUFFER_HDR_REG */ ret =3D regmap_bulk_write(pmic_typec_pdphy->regmap, pmic_typec_pdphy->base + USB_PDPHY_TX_BUFFER_HDR_REG, --=20 2.17.1