Skip to content

Commit 363c538

Browse files
Evan Greendtor
authored andcommitted
Input: synaptics-rmi4 - avoid processing unknown IRQs
rmi_process_interrupt_requests() calls handle_nested_irq() for each interrupt status bit it finds. If the irq domain mapping for this bit had not yet been set up, then it ends up calling handle_nested_irq(0), which causes a NULL pointer dereference. There's already code that masks the irq_status bits coming out of the hardware with current_irq_mask, presumably to avoid this situation. However current_irq_mask seems to more reflect the actual mask set in the hardware rather than the IRQs software has set up and registered for. For example, in rmi_driver_reset_handler(), the current_irq_mask is initialized based on what is read from the hardware. If the reset value of this mask enables IRQs that Linux has not set up yet, then we end up in this situation. There appears to be a third unused bitmask that used to serve this purpose, fn_irq_bits. Use that bitmask instead of current_irq_mask to avoid calling handle_nested_irq() on IRQs that have not yet been set up. Signed-off-by: Evan Green <[email protected]> Reviewed-by: Andrew Duggan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent bcf0595 commit 363c538

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/input/rmi4/rmi_driver.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev)
146146
}
147147

148148
mutex_lock(&data->irq_mutex);
149-
bitmap_and(data->irq_status, data->irq_status, data->current_irq_mask,
149+
bitmap_and(data->irq_status, data->irq_status, data->fn_irq_bits,
150150
data->irq_count);
151151
/*
152152
* At this point, irq_status has all bits that are set in the
@@ -385,6 +385,8 @@ static int rmi_driver_set_irq_bits(struct rmi_device *rmi_dev,
385385
bitmap_copy(data->current_irq_mask, data->new_irq_mask,
386386
data->num_of_irq_regs);
387387

388+
bitmap_or(data->fn_irq_bits, data->fn_irq_bits, mask, data->irq_count);
389+
388390
error_unlock:
389391
mutex_unlock(&data->irq_mutex);
390392
return error;
@@ -398,6 +400,8 @@ static int rmi_driver_clear_irq_bits(struct rmi_device *rmi_dev,
398400
struct device *dev = &rmi_dev->dev;
399401

400402
mutex_lock(&data->irq_mutex);
403+
bitmap_andnot(data->fn_irq_bits,
404+
data->fn_irq_bits, mask, data->irq_count);
401405
bitmap_andnot(data->new_irq_mask,
402406
data->current_irq_mask, mask, data->irq_count);
403407

0 commit comments

Comments
 (0)