diff options
author | Dong Fang <yp.fangdong@gmail.com> | 2013-09-11 17:19:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-11 18:56:36 -0400 |
commit | df53cd3b70712cd136f10ef79457623c5c3764a4 (patch) | |
tree | 426988282de0ac3ff6d00a51dc8f299e47dfeefc /fs/ocfs2/dlm/dlmconvert.c | |
parent | 8dd7903e48df3779bc424196c22dc73b66d0643e (diff) |
ocfs2: use list_for_each_entry() instead of list_for_each()
[dan.carpenter@oracle.com: fix up some NULL dereference bugs]
Signed-off-by: Dong Fang <yp.fangdong@gmail.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Jeff Liu <jeff.liu@oracle.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2/dlm/dlmconvert.c')
-rw-r--r-- | fs/ocfs2/dlm/dlmconvert.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/fs/ocfs2/dlm/dlmconvert.c b/fs/ocfs2/dlm/dlmconvert.c index 29a886d1e82c..e36d63ff1783 100644 --- a/fs/ocfs2/dlm/dlmconvert.c +++ b/fs/ocfs2/dlm/dlmconvert.c | |||
@@ -123,7 +123,6 @@ static enum dlm_status __dlmconvert_master(struct dlm_ctxt *dlm, | |||
123 | int *kick_thread) | 123 | int *kick_thread) |
124 | { | 124 | { |
125 | enum dlm_status status = DLM_NORMAL; | 125 | enum dlm_status status = DLM_NORMAL; |
126 | struct list_head *iter; | ||
127 | struct dlm_lock *tmplock=NULL; | 126 | struct dlm_lock *tmplock=NULL; |
128 | 127 | ||
129 | assert_spin_locked(&res->spinlock); | 128 | assert_spin_locked(&res->spinlock); |
@@ -185,16 +184,14 @@ static enum dlm_status __dlmconvert_master(struct dlm_ctxt *dlm, | |||
185 | 184 | ||
186 | /* upconvert from here on */ | 185 | /* upconvert from here on */ |
187 | status = DLM_NORMAL; | 186 | status = DLM_NORMAL; |
188 | list_for_each(iter, &res->granted) { | 187 | list_for_each_entry(tmplock, &res->granted, list) { |
189 | tmplock = list_entry(iter, struct dlm_lock, list); | ||
190 | if (tmplock == lock) | 188 | if (tmplock == lock) |
191 | continue; | 189 | continue; |
192 | if (!dlm_lock_compatible(tmplock->ml.type, type)) | 190 | if (!dlm_lock_compatible(tmplock->ml.type, type)) |
193 | goto switch_queues; | 191 | goto switch_queues; |
194 | } | 192 | } |
195 | 193 | ||
196 | list_for_each(iter, &res->converting) { | 194 | list_for_each_entry(tmplock, &res->converting, list) { |
197 | tmplock = list_entry(iter, struct dlm_lock, list); | ||
198 | if (!dlm_lock_compatible(tmplock->ml.type, type)) | 195 | if (!dlm_lock_compatible(tmplock->ml.type, type)) |
199 | goto switch_queues; | 196 | goto switch_queues; |
200 | /* existing conversion requests take precedence */ | 197 | /* existing conversion requests take precedence */ |
@@ -424,8 +421,8 @@ int dlm_convert_lock_handler(struct o2net_msg *msg, u32 len, void *data, | |||
424 | struct dlm_ctxt *dlm = data; | 421 | struct dlm_ctxt *dlm = data; |
425 | struct dlm_convert_lock *cnv = (struct dlm_convert_lock *)msg->buf; | 422 | struct dlm_convert_lock *cnv = (struct dlm_convert_lock *)msg->buf; |
426 | struct dlm_lock_resource *res = NULL; | 423 | struct dlm_lock_resource *res = NULL; |
427 | struct list_head *iter; | ||
428 | struct dlm_lock *lock = NULL; | 424 | struct dlm_lock *lock = NULL; |
425 | struct dlm_lock *tmp_lock; | ||
429 | struct dlm_lockstatus *lksb; | 426 | struct dlm_lockstatus *lksb; |
430 | enum dlm_status status = DLM_NORMAL; | 427 | enum dlm_status status = DLM_NORMAL; |
431 | u32 flags; | 428 | u32 flags; |
@@ -471,14 +468,13 @@ int dlm_convert_lock_handler(struct o2net_msg *msg, u32 len, void *data, | |||
471 | dlm_error(status); | 468 | dlm_error(status); |
472 | goto leave; | 469 | goto leave; |
473 | } | 470 | } |
474 | list_for_each(iter, &res->granted) { | 471 | list_for_each_entry(tmp_lock, &res->granted, list) { |
475 | lock = list_entry(iter, struct dlm_lock, list); | 472 | if (tmp_lock->ml.cookie == cnv->cookie && |
476 | if (lock->ml.cookie == cnv->cookie && | 473 | tmp_lock->ml.node == cnv->node_idx) { |
477 | lock->ml.node == cnv->node_idx) { | 474 | lock = tmp_lock; |
478 | dlm_lock_get(lock); | 475 | dlm_lock_get(lock); |
479 | break; | 476 | break; |
480 | } | 477 | } |
481 | lock = NULL; | ||
482 | } | 478 | } |
483 | spin_unlock(&res->spinlock); | 479 | spin_unlock(&res->spinlock); |
484 | if (!lock) { | 480 | if (!lock) { |