Skip to content

Commit 1b64daa

Browse files
committed
Merge tag 'scmi-smccc-fixes-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into arm/fixes
Arm SCMI and SMCCC fixes for v6.5 Set of fixes addressing issues: 1. Possible use of uninitialised results structure in the SMCCC SOC_ID driver if the driver fails to complete the initialisation 2. Missed signed error return value handling from simple_write_to_buffer() used in scmi_dbg_raw_mode_common_write() 3. The OF node reference obtained is not dropped if node is incompatible with "arm,scmi-shmem" in the mailbox as well as SMC transport channel setup 4. The possibility of a late response to an in-flight pending transaction that could end up triggering the interrupt handler after the SCMI core has cleaned up the transport channel as part of core driver remove * tag 'scmi-smccc-fixes-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux: firmware: arm_scmi: Fix chan_free cleanup on SMC firmware: arm_scmi: Drop OF node reference in the transport channel setup firmware: arm_scmi: Fix signed error return values handling firmware: smccc: Fix use of uninitialised results structure Link: https://lore.kernel.org/r/20230721114052.3371923-1-sudeep.holla@arm.com Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents f6ad3c1 + d1ff11d commit 1b64daa

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

drivers/firmware/arm_scmi/mailbox.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
166166
return -ENOMEM;
167167

168168
shmem = of_parse_phandle(cdev->of_node, "shmem", idx);
169-
if (!of_device_is_compatible(shmem, "arm,scmi-shmem"))
169+
if (!of_device_is_compatible(shmem, "arm,scmi-shmem")) {
170+
of_node_put(shmem);
170171
return -ENXIO;
172+
}
171173

172174
ret = of_address_to_resource(shmem, 0, &res);
173175
of_node_put(shmem);

drivers/firmware/arm_scmi/raw_mode.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,10 +818,13 @@ static ssize_t scmi_dbg_raw_mode_common_write(struct file *filp,
818818
* before sending it with a single RAW xfer.
819819
*/
820820
if (rd->tx_size < rd->tx_req_size) {
821-
size_t cnt;
821+
ssize_t cnt;
822822

823823
cnt = simple_write_to_buffer(rd->tx.buf, rd->tx.len, ppos,
824824
buf, count);
825+
if (cnt < 0)
826+
return cnt;
827+
825828
rd->tx_size += cnt;
826829
if (cnt < count)
827830
return cnt;

drivers/firmware/arm_scmi/smc.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
/**
4141
* struct scmi_smc - Structure representing a SCMI smc transport
4242
*
43+
* @irq: An optional IRQ for completion
4344
* @cinfo: SCMI channel info
4445
* @shmem: Transmit/Receive shared memory area
4546
* @shmem_lock: Lock to protect access to Tx/Rx shared memory area.
@@ -52,6 +53,7 @@
5253
*/
5354

5455
struct scmi_smc {
56+
int irq;
5557
struct scmi_chan_info *cinfo;
5658
struct scmi_shared_mem __iomem *shmem;
5759
/* Protect access to shmem area */
@@ -127,7 +129,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
127129
struct resource res;
128130
struct device_node *np;
129131
u32 func_id;
130-
int ret, irq;
132+
int ret;
131133

132134
if (!tx)
133135
return -ENODEV;
@@ -137,8 +139,10 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
137139
return -ENOMEM;
138140

139141
np = of_parse_phandle(cdev->of_node, "shmem", 0);
140-
if (!of_device_is_compatible(np, "arm,scmi-shmem"))
142+
if (!of_device_is_compatible(np, "arm,scmi-shmem")) {
143+
of_node_put(np);
141144
return -ENXIO;
145+
}
142146

143147
ret = of_address_to_resource(np, 0, &res);
144148
of_node_put(np);
@@ -167,11 +171,10 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
167171
* completion of a message is signaled by an interrupt rather than by
168172
* the return of the SMC call.
169173
*/
170-
irq = of_irq_get_byname(cdev->of_node, "a2p");
171-
if (irq > 0) {
172-
ret = devm_request_irq(dev, irq, smc_msg_done_isr,
173-
IRQF_NO_SUSPEND,
174-
dev_name(dev), scmi_info);
174+
scmi_info->irq = of_irq_get_byname(cdev->of_node, "a2p");
175+
if (scmi_info->irq > 0) {
176+
ret = request_irq(scmi_info->irq, smc_msg_done_isr,
177+
IRQF_NO_SUSPEND, dev_name(dev), scmi_info);
175178
if (ret) {
176179
dev_err(dev, "failed to setup SCMI smc irq\n");
177180
return ret;
@@ -193,6 +196,10 @@ static int smc_chan_free(int id, void *p, void *data)
193196
struct scmi_chan_info *cinfo = p;
194197
struct scmi_smc *scmi_info = cinfo->transport_info;
195198

199+
/* Ignore any possible further reception on the IRQ path */
200+
if (scmi_info->irq > 0)
201+
free_irq(scmi_info->irq, scmi_info);
202+
196203
cinfo->transport_info = NULL;
197204
scmi_info->cinfo = NULL;
198205

drivers/firmware/smccc/soc_id.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ static struct soc_device_attribute *soc_dev_attr;
3434

3535
static int __init smccc_soc_init(void)
3636
{
37-
struct arm_smccc_res res;
3837
int soc_id_rev, soc_id_version;
3938
static char soc_id_str[20], soc_id_rev_str[12];
4039
static char soc_id_jep106_id_str[12];
@@ -49,13 +48,13 @@ static int __init smccc_soc_init(void)
4948
}
5049

5150
if (soc_id_version < 0) {
52-
pr_err("ARCH_SOC_ID(0) returned error: %lx\n", res.a0);
51+
pr_err("Invalid SoC Version: %x\n", soc_id_version);
5352
return -EINVAL;
5453
}
5554

5655
soc_id_rev = arm_smccc_get_soc_id_revision();
5756
if (soc_id_rev < 0) {
58-
pr_err("ARCH_SOC_ID(1) returned error: %lx\n", res.a0);
57+
pr_err("Invalid SoC Revision: %x\n", soc_id_rev);
5958
return -EINVAL;
6059
}
6160

0 commit comments

Comments
 (0)