Skip to content

Commit ee0316b

Browse files
committed
mei: vsc: Event notifier fixes
JIRA: https://issues.redhat.com/browse/RHEL-113185 commit 18f14b2 Author: Hans de Goede <hansg@kernel.org> Date: Mon Jun 23 10:50:48 2025 +0200 mei: vsc: Event notifier fixes vsc_tp_register_event_cb() can race with vsc_tp_thread_isr(), add a mutex to protect against this. Fixes: 566f5ca ("mei: Add transport driver for IVSC device") Signed-off-by: Hans de Goede <hansg@kernel.org> Link: https://lore.kernel.org/r/20250623085052.12347-7-hansg@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Steve Best <sbest@redhat.com>
1 parent 1d25943 commit ee0316b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/misc/mei/vsc-tp.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ struct vsc_tp {
7979

8080
vsc_tp_event_cb_t event_notify;
8181
void *event_notify_context;
82-
83-
/* used to protect command download */
84-
struct mutex mutex;
82+
struct mutex event_notify_mutex; /* protects event_notify + context */
83+
struct mutex mutex; /* protects command download */
8584
};
8685

8786
/* GPIO resources */
@@ -113,6 +112,8 @@ static irqreturn_t vsc_tp_thread_isr(int irq, void *data)
113112
{
114113
struct vsc_tp *tp = data;
115114

115+
guard(mutex)(&tp->event_notify_mutex);
116+
116117
if (tp->event_notify)
117118
tp->event_notify(tp->event_notify_context);
118119

@@ -399,6 +400,8 @@ EXPORT_SYMBOL_NS_GPL(vsc_tp_need_read, "VSC_TP");
399400
int vsc_tp_register_event_cb(struct vsc_tp *tp, vsc_tp_event_cb_t event_cb,
400401
void *context)
401402
{
403+
guard(mutex)(&tp->event_notify_mutex);
404+
402405
tp->event_notify = event_cb;
403406
tp->event_notify_context = context;
404407

@@ -499,6 +502,7 @@ static int vsc_tp_probe(struct spi_device *spi)
499502
return ret;
500503

501504
mutex_init(&tp->mutex);
505+
mutex_init(&tp->event_notify_mutex);
502506

503507
/* only one child acpi device */
504508
ret = acpi_dev_for_each_child(ACPI_COMPANION(dev),
@@ -523,6 +527,7 @@ static int vsc_tp_probe(struct spi_device *spi)
523527
err_destroy_lock:
524528
free_irq(spi->irq, tp);
525529

530+
mutex_destroy(&tp->event_notify_mutex);
526531
mutex_destroy(&tp->mutex);
527532

528533
return ret;
@@ -537,6 +542,7 @@ static void vsc_tp_remove(struct spi_device *spi)
537542

538543
free_irq(spi->irq, tp);
539544

545+
mutex_destroy(&tp->event_notify_mutex);
540546
mutex_destroy(&tp->mutex);
541547
}
542548

0 commit comments

Comments
 (0)