From: Alexander Aring Date: Thu, 21 Jul 2022 17:53:39 -0400 Subject: [Cluster-devel] [PATCH dlm/next 2/3] fs: dlm: avoid double list_add() for lkb->lkb_cb_list In-Reply-To: <20220721215340.936838-1-aahringo@redhat.com> References: <20220721215340.936838-1-aahringo@redhat.com> Message-ID: <20220721215340.936838-3-aahringo@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit The dlm_add_cb() can run multiple times for a lkb to add a callback and calling list_add() to calling queue_work() for later. If it's getting called multiple times while test_bit(LSFL_CB_DELAY, &ls->ls_flags) is true we need to ensure it was added only once or the list getting corrupted. The list holder lkb->lkb_cb_list is being used with list_del_init()/INIT_LIST_HEAD() and can be used with list_empty() to check if it is not being part of a list. Cc: stable at vger.kernel.org Signed-off-by: Alexander Aring --- fs/dlm/ast.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c index a44cc42b6317..0271796d36b1 100644 --- a/fs/dlm/ast.c +++ b/fs/dlm/ast.c @@ -202,7 +202,8 @@ void dlm_add_cb(struct dlm_lkb *lkb, uint32_t flags, int mode, int status, mutex_lock(&ls->ls_cb_mutex); if (test_bit(LSFL_CB_DELAY, &ls->ls_flags)) { - list_add(&lkb->lkb_cb_list, &ls->ls_cb_delay); + if (list_empty(&lkb->lkb_cb_list)) + list_add(&lkb->lkb_cb_list, &ls->ls_cb_delay); } else { queue_work(ls->ls_callback_wq, &lkb->lkb_cb_work); } -- 2.31.1