Skip to content

Commit

Permalink
staging: gasket: interrupt: fix the missed eventfd_ctx_put() in gaske…
Browse files Browse the repository at this point in the history
…t_interrupt.c

[ Upstream commit ab5b769 ]

gasket_interrupt_set_eventfd() misses to call eventfd_ctx_put() in an
error path. We check interrupt is valid before calling
eventfd_ctx_fdget() to fix it.

There is the same issue in gasket_interrupt_clear_eventfd(), Add the
missed function call to fix it.

Fixes: 9a69f50 ("drivers/staging: Gasket driver framework + Apex driver")
Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
Link: https://lore.kernel.org/r/20201112064924.99680-1-jingxiangfeng@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
hiss2018 authored and gregkh committed Dec 30, 2020
1 parent 63c4e01 commit 7f1cae8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions drivers/staging/gasket/gasket_interrupt.c
Expand Up @@ -487,14 +487,16 @@ int gasket_interrupt_system_status(struct gasket_dev *gasket_dev)
int gasket_interrupt_set_eventfd(struct gasket_interrupt_data *interrupt_data,
int interrupt, int event_fd)
{
struct eventfd_ctx *ctx = eventfd_ctx_fdget(event_fd);

if (IS_ERR(ctx))
return PTR_ERR(ctx);
struct eventfd_ctx *ctx;

if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts)
return -EINVAL;

ctx = eventfd_ctx_fdget(event_fd);

if (IS_ERR(ctx))
return PTR_ERR(ctx);

interrupt_data->eventfd_ctxs[interrupt] = ctx;
return 0;
}
Expand All @@ -505,6 +507,9 @@ int gasket_interrupt_clear_eventfd(struct gasket_interrupt_data *interrupt_data,
if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts)
return -EINVAL;

interrupt_data->eventfd_ctxs[interrupt] = NULL;
if (interrupt_data->eventfd_ctxs[interrupt]) {
eventfd_ctx_put(interrupt_data->eventfd_ctxs[interrupt]);
interrupt_data->eventfd_ctxs[interrupt] = NULL;
}
return 0;
}

0 comments on commit 7f1cae8

Please sign in to comment.