Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761607Ab0HGJJT (ORCPT ); Sat, 7 Aug 2010 05:09:19 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:41594 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753036Ab0HGJJR (ORCPT ); Sat, 7 Aug 2010 05:09:17 -0400 Date: Sat, 7 Aug 2010 11:09:13 +0200 (CEST) From: Julia Lawall To: Mark Fasheh , Joel Becker , ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry loop cursor Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1659 Lines: 60 From: Julia Lawall list_for_each_entry uses its first argument to move from one element to the next, so modifying it can break the iteration. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ iterator name list_for_each_entry; expression x,E; position p1,p2; @@ list_for_each_entry@p1(x,...) { <... x =@p2 E ...> } @@ expression x,E; position r.p1,r.p2; statement S; @@ *x =@p2 E ... list_for_each_entry@p1(x,...) S // Signed-off-by: Julia Lawall --- I don't know whether this is the right solution, but it seems plausible considering the subsequent test on lock. In any case, setting lock to NULL and then going back to the top of the loop does not work. fs/ocfs2/dlm/dlmrecovery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index 9dfaac7..7084a11 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -1792,10 +1792,10 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm, for (j = DLM_GRANTED_LIST; j <= DLM_BLOCKED_LIST; j++) { tmpq = dlm_list_idx_to_ptr(res, j); list_for_each_entry(lock, tmpq, list) { - if (lock->ml.cookie != ml->cookie) + if (lock->ml.cookie != ml->cookie) { lock = NULL; - else break; + } } if (lock) break; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/