]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ocfs2/dlm: fix off-by-one in dlm_match_regions() region comparison
authorJunrui Luo <moonafterrain@outlook.com>
Sat, 7 Mar 2026 07:21:09 +0000 (15:21 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 28 Mar 2026 04:19:49 +0000 (21:19 -0700)
The local-vs-remote region comparison loop uses '<=' instead of '<',
causing it to read one entry past the valid range of qr_regions.  The
other loops in the same function correctly use '<'.

Fix the loop condition to use '<' for consistency and correctness.

Link: https://lkml.kernel.org/r/SYBPR01MB78813DA26B50EC5E01F00566AF7BA@SYBPR01MB7881.ausprd01.prod.outlook.com
Fixes: ea2034416b54 ("ocfs2/dlm: Add message DLM_QUERY_REGION")
Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
Reported-by: Yuhao Jiang <danisjiang@gmail.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Cc: Heming Zhao <heming.zhao@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ocfs2/dlm/dlmdomain.c

index 0a28cb5ded2ab3e4a3cd88297c4ca34655c1c6af..dc9da9133c8ee60f59cf6d6da15e8b3211e70c2b 100644 (file)
@@ -1002,7 +1002,7 @@ static int dlm_match_regions(struct dlm_ctxt *dlm,
        for (i = 0; i < localnr; ++i) {
                foundit = 0;
                r = remote;
-               for (j = 0; j <= qr->qr_numregions; ++j) {
+               for (j = 0; j < qr->qr_numregions; ++j) {
                        if (!memcmp(l, r, O2HB_MAX_REGION_NAME_LEN)) {
                                foundit = 1;
                                break;