When first command line argument after "-Q" is "queue_mask", we parse
the queue mask and following subcommand without checking if these
arguments do actually exist. Add check if we have at least two arguments
left after "queue_mask" in the corresponding branch.

Fixes: 9ecd54248b1a ("ethtool: introduce new ioctl for per-queue settings")
Signed-off-by: Michal Kubecek <mkube...@suse.cz>
---
 ethtool.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ethtool.c b/ethtool.c
index 4fa7a2c1716f..6c12452be7b4 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -5880,6 +5880,8 @@ static int do_perqueue(struct cmd_context *ctx)
                        "The sub commands will be applied to all %d queues\n",
                        n_queues);
        } else {
+               if (ctx->argc <= 2)
+                       exit_bad_args();
                ctx->argc--;
                ctx->argp++;
                if (parse_hex_u32_bitmap(*ctx->argp, MAX_NUM_QUEUE,
-- 
2.28.0

Reply via email to