Skip to content

Commit 69bef19

Browse files
limeng-linuxbrgl
authored andcommitted
gpiolib: cdev: Set lineevent_state::irq after IRQ register successfully
When running gpio test on nxp-ls1028 platform with below command gpiomon --num-events=3 --rising-edge gpiochip1 25 There will be a warning trace as below: Call trace: free_irq+0x204/0x360 lineevent_free+0x64/0x70 gpio_ioctl+0x598/0x6a0 __arm64_sys_ioctl+0xb4/0x100 invoke_syscall+0x5c/0x130 ...... el0t_64_sync+0x1a0/0x1a4 The reason of this issue is that calling request_threaded_irq() function failed, and then lineevent_free() is invoked to release the resource. Since the lineevent_state::irq was already set, so the subsequent invocation of free_irq() would trigger the above warning call trace. To fix this issue, set the lineevent_state::irq after the IRQ register successfully. Fixes: 4682427 ("gpiolib: cdev: refactor lineevent cleanup into lineevent_free") Cc: [email protected] Signed-off-by: Meng Li <[email protected]> Reviewed-by: Kent Gibson <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 21a9acc commit 69bef19

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/gpio/gpiolib-cdev.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
19861986
ret = -ENODEV;
19871987
goto out_free_le;
19881988
}
1989-
le->irq = irq;
19901989

19911990
if (eflags & GPIOEVENT_REQUEST_RISING_EDGE)
19921991
irqflags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ?
@@ -2000,7 +1999,7 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
20001999
init_waitqueue_head(&le->wait);
20012000

20022001
/* Request a thread to read the events */
2003-
ret = request_threaded_irq(le->irq,
2002+
ret = request_threaded_irq(irq,
20042003
lineevent_irq_handler,
20052004
lineevent_irq_thread,
20062005
irqflags,
@@ -2009,6 +2008,8 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
20092008
if (ret)
20102009
goto out_free_le;
20112010

2011+
le->irq = irq;
2012+
20122013
fd = get_unused_fd_flags(O_RDONLY | O_CLOEXEC);
20132014
if (fd < 0) {
20142015
ret = fd;

0 commit comments

Comments
 (0)