All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: event: Ensure atomicity for sequence number
@ 2024-01-04 14:13 Naresh Solanki
  2024-01-05  7:07 ` Matti Vaittinen
  2024-01-05 13:04 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Naresh Solanki @ 2024-01-04 14:13 UTC (permalink / raw)
  To: broonie, Liam Girdwood; +Cc: mazziesaccount, Naresh Solanki, linux-kernel

Previously, the sequence number in the regulator event subsystem was
updated without atomic operations, potentially leading to race
conditions. This commit addresses the issue by making the sequence
number atomic.

Signed-off-by: Naresh Solanki <naresh.solanki@9elements.com>
---
 drivers/regulator/event.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/event.c b/drivers/regulator/event.c
index 0ec58f306b38..ea3bd49544e8 100644
--- a/drivers/regulator/event.c
+++ b/drivers/regulator/event.c
@@ -8,10 +8,11 @@
 #include <regulator/regulator.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
+#include <linux/atomic.h>
 
 #include "regnl.h"
 
-static unsigned int reg_event_seqnum;
+static atomic_t reg_event_seqnum = ATOMIC_INIT(0);
 
 static const struct genl_multicast_group reg_event_mcgrps[] = {
 	{ .name = REG_GENL_MCAST_GROUP_NAME, },
@@ -43,9 +44,8 @@ int reg_generate_netlink_event(const char *reg_name, u64 event)
 		return -ENOMEM;
 
 	/* add the genetlink message header */
-	msg_header = genlmsg_put(skb, 0, reg_event_seqnum++,
-				 &reg_event_genl_family, 0,
-				 REG_GENL_CMD_EVENT);
+	msg_header = genlmsg_put(skb, 0, atomic_inc_return(&reg_event_seqnum),
+				 &reg_event_genl_family, 0, REG_GENL_CMD_EVENT);
 	if (!msg_header) {
 		nlmsg_free(skb);
 		return -ENOMEM;

base-commit: 67ba055dd7758c34f6e64c9d35132362c1e1f0b5
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] regulator: event: Ensure atomicity for sequence number
  2024-01-04 14:13 [PATCH] regulator: event: Ensure atomicity for sequence number Naresh Solanki
@ 2024-01-05  7:07 ` Matti Vaittinen
  2024-01-05 13:04 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Matti Vaittinen @ 2024-01-05  7:07 UTC (permalink / raw)
  To: Naresh Solanki, broonie, Liam Girdwood; +Cc: linux-kernel

Hi Naresh,

On 1/4/24 16:13, Naresh Solanki wrote:
> Previously, the sequence number in the regulator event subsystem was
> updated without atomic operations, potentially leading to race
> conditions. This commit addresses the issue by making the sequence
> number atomic.
> 
> Signed-off-by: Naresh Solanki <naresh.solanki@9elements.com>

Maybe this deserves a Fixes tag?

Other than that this looks great - Thanks!

Yours,
	-- Matti


-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] regulator: event: Ensure atomicity for sequence number
  2024-01-04 14:13 [PATCH] regulator: event: Ensure atomicity for sequence number Naresh Solanki
  2024-01-05  7:07 ` Matti Vaittinen
@ 2024-01-05 13:04 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2024-01-05 13:04 UTC (permalink / raw)
  To: Liam Girdwood, Naresh Solanki; +Cc: mazziesaccount, linux-kernel

On Thu, 04 Jan 2024 19:43:13 +0530, Naresh Solanki wrote:
> Previously, the sequence number in the regulator event subsystem was
> updated without atomic operations, potentially leading to race
> conditions. This commit addresses the issue by making the sequence
> number atomic.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: event: Ensure atomicity for sequence number
      commit: 1cadc04c1a1ac5015c2eb0fadfabf4b61bbe167e

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-05 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-04 14:13 [PATCH] regulator: event: Ensure atomicity for sequence number Naresh Solanki
2024-01-05  7:07 ` Matti Vaittinen
2024-01-05 13:04 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.