Skip to content

Commit bc4d17e

Browse files
vfalanisJassi Brar
authored andcommitted
mailbox: mchp-ipc-sbi: fix uninitialized symbol and other smatch warnings
Fix uninitialized symbol 'hartid' warning in mchp_ipc_cluster_aggr_isr() by introducing a 'found' flag to track whether the IRQ matches any online hart. If no match is found, return IRQ_NONE. Also fix other smatch warnings by removing dead code in mchp_ipc_startup() and by returning -ENODEV in dev_err_probe() if the Microchip SBI extension is not found. Fixes below smatch warnings: drivers/mailbox/mailbox-mchp-ipc-sbi.c:187 mchp_ipc_cluster_aggr_isr() error: uninitialized symbol 'hartid'. drivers/mailbox/mailbox-mchp-ipc-sbi.c:324 mchp_ipc_startup() warn: ignoring unreachable code. drivers/mailbox/mailbox-mchp-ipc-sbi.c:422 mchp_ipc_probe() warn: passing zero to 'dev_err_probe' Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202512171533.CDLdScMY-lkp@intel.com/ Signed-off-by: Valentina Fernandez <valentina.fernandezalanis@microchip.com> Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
1 parent 9cf4d3f commit bc4d17e

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

drivers/mailbox/mailbox-mchp-ipc-sbi.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,21 @@ static irqreturn_t mchp_ipc_cluster_aggr_isr(int irq, void *data)
174174
struct mchp_ipc_msg ipc_msg;
175175
struct mchp_ipc_status status_msg;
176176
int ret;
177-
unsigned long hartid;
178177
u32 i, chan_index, chan_id;
178+
bool found = false;
179179

180180
/* Find out the hart that originated the irq */
181181
for_each_online_cpu(i) {
182-
hartid = cpuid_to_hartid_map(i);
183-
if (irq == ipc->cluster_cfg[i].irq)
182+
if (irq == ipc->cluster_cfg[i].irq) {
183+
found = true;
184184
break;
185+
}
185186
}
186187

187-
status_msg.cluster = hartid;
188+
if (unlikely(!found))
189+
return IRQ_NONE;
190+
191+
status_msg.cluster = cpuid_to_hartid_map(i);
188192
memcpy(ipc->cluster_cfg[i].buf_base, &status_msg, sizeof(struct mchp_ipc_status));
189193

190194
ret = mchp_ipc_sbi_send(SBI_EXT_IPC_STATUS, ipc->cluster_cfg[i].buf_base_addr);
@@ -321,13 +325,6 @@ static int mchp_ipc_startup(struct mbox_chan *chan)
321325
goto fail_free_buf_msg_rx;
322326
}
323327

324-
if (ret) {
325-
dev_err(ipc->dev, "failed to register interrupt(s)\n");
326-
goto fail_free_buf_msg_rx;
327-
}
328-
329-
return ret;
330-
331328
fail_free_buf_msg_rx:
332329
kfree(chan_info->msg_buf_rx);
333330
fail_free_buf_msg_tx:
@@ -419,7 +416,7 @@ static int mchp_ipc_probe(struct platform_device *pdev)
419416

420417
ret = sbi_probe_extension(SBI_EXT_MICROCHIP_TECHNOLOGY);
421418
if (ret <= 0)
422-
return dev_err_probe(dev, ret, "Microchip SBI extension not detected\n");
419+
return dev_err_probe(dev, -ENODEV, "Microchip SBI extension not detected\n");
423420

424421
ipc = devm_kzalloc(dev, sizeof(*ipc), GFP_KERNEL);
425422
if (!ipc)

0 commit comments

Comments
 (0)