Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7734519rdb; Thu, 4 Jan 2024 06:13:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFm7SeID7Slvz/86q6XoovInqDUh8FFoma2wlUqiW0agHZ6sdVJ4jkaq6xiHbFbl5BqCnUi X-Received: by 2002:a05:6e02:164e:b0:360:695:2c42 with SMTP id v14-20020a056e02164e00b0036006952c42mr798132ilu.57.1704377608614; Thu, 04 Jan 2024 06:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704377608; cv=none; d=google.com; s=arc-20160816; b=ZhndnxUAHdHiHB/iC2LOViXv/j4hhV9uCo9EumPdlINm0r3270Jzk6wc0zAAAfJJxi PXFdvyQOpkKFqXRy6V6/ofie1EEF7TPe52DStymnykLUv0/a2jz9snMI5kgbpsvOHBuJ 0n7iI0GYUuAtDVwD6I+gtkNXRVL3cC2nmEhl/gj+jOBp3k+yZFoBh4szsD6+n6DViGnF S7wr7fIU2Lvmo0McbIvv9uHQbfyNZAAsxIQfudWi0/6O6G2VkODCJb5g3MyIpeYdbhkR tH26hi/IuPtRCKw9oLRRKJpfDjW7JJqUxwJ7s1dNQW4uTLudREmHZHFKpjaw+fkkkZAk RfzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=IisSOi1IhKaF5rBKbPxKm8c6DbGMBvt8EnvrHA2VnKU=; fh=XKr2HKicqLPg7QxPfVubnGQhEy23tXK1UhNMgL63WW4=; b=dS5AoJqT0OHdqP5oxNVxjgYh5Kj5qtlPZbRg5NXtKY1AjZUW+qSggjl69MzpKXo/FG RmOOodEXGblyeEAzaLrGo1ZvCtYjVHzj3+OvnAwg6LECts+b7IIRNmKzZJfnLQPeLUpd +k6ICz8PB2XsjgyXfu3+yktJZX5Bv1bdSdVkxi3KFqmJB7s7Iatkvi1aAWEaPcTMubFW SMo3mim9FkkZEPMMVZqvYAfHbLios61dwSHUp7CN5j/UD3X7WoO0kT+UemVPdgcUhMZd OpM8RrEmLHD8lGzovlG0nfRhZcQXd6qc6z0i0GbgHKTpFLVw4q/ol2zSWlQcxwN9rixr GbRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=VlA8CZgE; spf=pass (google.com: domain of linux-kernel+bounces-16754-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16754-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l30-20020a63571e000000b005c6260b688esi23516896pgb.606.2024.01.04.06.13.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 06:13:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16754-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=VlA8CZgE; spf=pass (google.com: domain of linux-kernel+bounces-16754-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16754-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 351C1285D8B for ; Thu, 4 Jan 2024 14:13:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9592E224C0; Thu, 4 Jan 2024 14:13:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=9elements.com header.i=@9elements.com header.b="VlA8CZgE" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C99CF22304 for ; Thu, 4 Jan 2024 14:13:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=9elements.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=9elements.com Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3374eb61cbcso516382f8f.0 for ; Thu, 04 Jan 2024 06:13:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1704377598; x=1704982398; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IisSOi1IhKaF5rBKbPxKm8c6DbGMBvt8EnvrHA2VnKU=; b=VlA8CZgE29NnLdqA+aVG5OO9LbumJzjH3gP3nNulHUusebuQNvWJcEwVXDV9qL+xFv RCAoIaTbMK5LnZxjcQwwHqbymfq7VMJrVhxHqpJ0fsyNM+61A5HohILOLSd892BfLQw7 9m72ntY3mBibTRYX54l6wgCkhaBL0VBu4fkyuHi0GtgsDk/HSCyPmAV4Ybh7moc5b43l +7gU3GCfrh9M5q49Vx8QyhK4J1wyvineZqAXAOnWTQRokc69M1gpLt9LGvt4xzNC8K7e wbuMGkEPUxaZsXFrXsyZixB/elMwLZ4SxBIwwPp/fAbD9g+UuVRCaQt1tGi0izs8ORQJ SM+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704377598; x=1704982398; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IisSOi1IhKaF5rBKbPxKm8c6DbGMBvt8EnvrHA2VnKU=; b=bjDwk4J8MQlvojpUf5GzWcoidmIlyIjz7RXOJyGMI+OvlJ/Y6QugjFfHAHOayVOFv8 yZC5TSFt+BmLuUx4Rd9s42Ioa/pc5dkfGbHIPriIYMh7yjD608aVkbYyWrurvBNUy1Wu r90GaoFP7ujBvkFLeKohqTwhMgVsWhM+DeppMoTbEC5c9Nzll7QZKc4n5DZ6RdV37m2P +RAorF5Sj9ZP56lpBisSkSnQJgLf6rHbaJOHRNHnl+Qa79l5M/XcQoe/HqAju0seo9Yt xjA/HxSdiZpzHeFFlRIEKCIE+UAE4J2kZ1BQEw1ocIo7qGFjvZ6yvR7T1h5HH+AvwrNF FTCg== X-Gm-Message-State: AOJu0YyK6icplEzv8sJuG2+vUBI7ah4Iv+rHjQ5qmKicLsFNV+2xTJIF G7lpMp2Y3tbT0rG6D8QwXTn3hB59iNGzHg== X-Received: by 2002:a05:600c:354b:b0:40d:91f8:a663 with SMTP id i11-20020a05600c354b00b0040d91f8a663mr401331wmq.23.1704377597700; Thu, 04 Jan 2024 06:13:17 -0800 (PST) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id u17-20020a5d4351000000b00336f05840c4sm20324420wrr.100.2024.01.04.06.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 06:13:16 -0800 (PST) From: Naresh Solanki To: broonie@kernel.org, Liam Girdwood Cc: mazziesaccount@gmail.com, Naresh Solanki , linux-kernel@vger.kernel.org Subject: [PATCH] regulator: event: Ensure atomicity for sequence number Date: Thu, 4 Jan 2024 19:43:13 +0530 Message-ID: <20240104141314.3337037-1-naresh.solanki@9elements.com> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 #include #include +#include #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++, - ®_event_genl_family, 0, - REG_GENL_CMD_EVENT); + msg_header = genlmsg_put(skb, 0, atomic_inc_return(®_event_seqnum), + ®_event_genl_family, 0, REG_GENL_CMD_EVENT); if (!msg_header) { nlmsg_free(skb); return -ENOMEM; base-commit: 67ba055dd7758c34f6e64c9d35132362c1e1f0b5 -- 2.41.0