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

Merge tag 'counter-fixes-for-6.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wbg/counter into char-misc-next

William writes:

Counter fixes for 6.15

A fix to prevent a race condition when accessing the Count enable
component in interrupt-cnt.

* tag 'counter-fixes-for-6.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wbg/counter:
counter: interrupt-cnt: Protect enable/disable OPs with mutex

+9
+9
drivers/counter/interrupt-cnt.c
··· 3 3 * Copyright (c) 2021 Pengutronix, Oleksij Rempel <kernel@pengutronix.de> 4 4 */ 5 5 6 + #include <linux/cleanup.h> 6 7 #include <linux/counter.h> 7 8 #include <linux/gpio/consumer.h> 8 9 #include <linux/interrupt.h> 9 10 #include <linux/irq.h> 10 11 #include <linux/mod_devicetable.h> 11 12 #include <linux/module.h> 13 + #include <linux/mutex.h> 12 14 #include <linux/platform_device.h> 13 15 #include <linux/types.h> 14 16 ··· 21 19 struct gpio_desc *gpio; 22 20 int irq; 23 21 bool enabled; 22 + struct mutex lock; 24 23 struct counter_signal signals; 25 24 struct counter_synapse synapses; 26 25 struct counter_count cnts; ··· 44 41 { 45 42 struct interrupt_cnt_priv *priv = counter_priv(counter); 46 43 44 + guard(mutex)(&priv->lock); 45 + 47 46 *enable = priv->enabled; 48 47 49 48 return 0; ··· 55 50 struct counter_count *count, u8 enable) 56 51 { 57 52 struct interrupt_cnt_priv *priv = counter_priv(counter); 53 + 54 + guard(mutex)(&priv->lock); 58 55 59 56 if (priv->enabled == enable) 60 57 return 0; ··· 233 226 dev_name(dev), counter); 234 227 if (ret) 235 228 return ret; 229 + 230 + mutex_init(&priv->lock); 236 231 237 232 ret = devm_counter_add(dev, counter); 238 233 if (ret < 0)