mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kovalev@altlinux.org
To: mst@redhat.com, jasowang@redhat.com, parav@nvidia.com,
	edumazet@google.com, elic@nvidia.com,
	linux-kernel@vger.kernel.org
Cc: kovalev@altlinux.org
Subject: [PATCH] vDPA: fix incorrect VDPA_ATTR_MAX value
Date: Mon, 15 Apr 2024 19:37:07 +0300	[thread overview]
Message-ID: <20240415163707.517820-1-kovalev@altlinux.org> (raw)

From: Vasiliy Kovalev <kovalev@altlinux.org>

The VDPA_ATTR_MAX value should correspond to the index of the last
available member of the structure, not their total number.

Otherwise, it can lead to interpretation errors in other functions
when the structure (.maxattr = VDPA_ATTR_MAX) member is actually
incremented by one and refers to invalid data.

Fixes: 33b347503f01 ("vdpa: Define vdpa mgmt device, ops and a netlink interface")
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
---
 include/uapi/linux/vdpa.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/vdpa.h b/include/uapi/linux/vdpa.h
index 43c51698195ceb..ab132a09565232 100644
--- a/include/uapi/linux/vdpa.h
+++ b/include/uapi/linux/vdpa.h
@@ -74,7 +74,8 @@ enum vdpa_attr {
 	VDPA_ATTR_DEV_BLK_CFG_FLUSH,		/* u8 */
 
 	/* new attributes must be added above here */
-	VDPA_ATTR_MAX,
+	__VDPA_ATTR_MAX,
+	VDPA_ATTR_MAX	= __VDPA_ATTR_MAX - 1,
 };
 
 #endif
-- 
2.33.8


             reply	other threads:[~2024-04-15 16:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 16:37 kovalev [this message]
2024-04-16  7:18 ` Jason Wang
2024-04-16  7:22   ` Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240415163707.517820-1-kovalev@altlinux.org \
    --to=kovalev@altlinux.org \
    --cc=edumazet@google.com \
    --cc=elic@nvidia.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=parav@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®