Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip/riscv-imsic: Revert "Remove redundant irq_data lookups"

Commit c475c0b71314("irqchip/riscv-imsic: Remove redundant irq_data
lookups") leads to a NULL pointer deference in imsic_msi_update_msg():

virtio_blk virtio1: 8/0/0 default/read/poll queues
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
Current kworker/u32:2 pgtable: 4K pagesize, 48-bit VAs, pgdp=0x0000000081c33000
[0000000000000000] pgd=0000000000000000, p4d=0000000000000000
CPU: 5 UID: 0 PID: 75 Comm: kworker/u32:2 Not tainted 6.19.0-rc4-next-20260109 #1 NONE
epc : 0x0
ra : imsic_irq_set_affinity+0x110/0x130

The irq_data argument of imsic_irq_set_affinity() is associated with the
imsic domain and not with the top-level MSI domain. As a consequence the
code dereferences the wrong interrupt chip, which has the
irq_write_msi_msg() callback not populated.

Signed-off-by: Luo Haiyang <luo.haiyang@zte.com.cn>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260113111930821RrC26avITHWSFCN0bYbgI@zte.com.cn

authored by

Luo Haiyang and committed by
Thomas Gleixner
f2edf797 0f61b186

+2 -2
+2 -2
drivers/irqchip/irq-riscv-imsic-platform.c
··· 158 158 tmp_vec.local_id = new_vec->local_id; 159 159 160 160 /* Point device to the temporary vector */ 161 - imsic_msi_update_msg(d, &tmp_vec); 161 + imsic_msi_update_msg(irq_get_irq_data(d->irq), &tmp_vec); 162 162 } 163 163 164 164 /* Point device to the new vector */ 165 - imsic_msi_update_msg(d, new_vec); 165 + imsic_msi_update_msg(irq_get_irq_data(d->irq), new_vec); 166 166 167 167 /* Update irq descriptors with the new vector */ 168 168 d->chip_data = new_vec;