Skip to content

Commit

Permalink
hlist: drop the node parameter from iterators
Browse files Browse the repository at this point in the history
I'm not sure why, but the hlist for each entry iterators were conceived

        list_for_each_entry(pos, head, member)

The hlist ones were greedy and wanted an extra parameter:

        hlist_for_each_entry(tpos, pos, head, member)

Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.

Besides the semantic patch, there was some manual work required:

 - Fix up the actual hlist iterators in linux/list.h
 - Fix up the declaration of other iterators based on the hlist ones.
 - A very small amount of places were using the 'node' parameter, this
 was modified to use 'obj->member' instead.
 - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
 properly, so those had to be fixed up manually.

The semantic patch which is mostly the work of Peter Senna Tschudin is here:

@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;

type T;
expression a,c,d,e;
identifier b;
statement S;
@@

-T b;
    <+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
    ...+>

[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
sashalevin authored and torvalds committed Feb 28, 2013
1 parent 1e142b2 commit b67bfe0
Show file tree
Hide file tree
Showing 218 changed files with 987 additions and 1,494 deletions.
6 changes: 3 additions & 3 deletions arch/arm/kernel/kprobes.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
{ {
struct kretprobe_instance *ri = NULL; struct kretprobe_instance *ri = NULL;
struct hlist_head *head, empty_rp; struct hlist_head *head, empty_rp;
struct hlist_node *node, *tmp; struct hlist_node *tmp;
unsigned long flags, orig_ret_address = 0; unsigned long flags, orig_ret_address = 0;
unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline; unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline;


Expand All @@ -415,7 +415,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
* real return address, and all the rest will point to * real return address, and all the rest will point to
* kretprobe_trampoline * kretprobe_trampoline
*/ */
hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current) if (ri->task != current)
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
Expand All @@ -442,7 +442,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
kretprobe_assert(ri, orig_ret_address, trampoline_address); kretprobe_assert(ri, orig_ret_address, trampoline_address);
kretprobe_hash_unlock(current, &flags); kretprobe_hash_unlock(current, &flags);


hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist); hlist_del(&ri->hlist);
kfree(ri); kfree(ri);
} }
Expand Down
8 changes: 4 additions & 4 deletions arch/ia64/kernel/kprobes.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
{ {
struct kretprobe_instance *ri = NULL; struct kretprobe_instance *ri = NULL;
struct hlist_head *head, empty_rp; struct hlist_head *head, empty_rp;
struct hlist_node *node, *tmp; struct hlist_node *tmp;
unsigned long flags, orig_ret_address = 0; unsigned long flags, orig_ret_address = 0;
unsigned long trampoline_address = unsigned long trampoline_address =
((struct fnptr *)kretprobe_trampoline)->ip; ((struct fnptr *)kretprobe_trampoline)->ip;
Expand All @@ -444,7 +444,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
* real return address, and all the rest will point to * real return address, and all the rest will point to
* kretprobe_trampoline * kretprobe_trampoline
*/ */
hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current) if (ri->task != current)
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
Expand All @@ -461,7 +461,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)


regs->cr_iip = orig_ret_address; regs->cr_iip = orig_ret_address;


hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current) if (ri->task != current)
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
Expand All @@ -487,7 +487,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
kretprobe_hash_unlock(current, &flags); kretprobe_hash_unlock(current, &flags);
preempt_enable_no_resched(); preempt_enable_no_resched();


hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist); hlist_del(&ri->hlist);
kfree(ri); kfree(ri);
} }
Expand Down
6 changes: 3 additions & 3 deletions arch/mips/kernel/kprobes.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
{ {
struct kretprobe_instance *ri = NULL; struct kretprobe_instance *ri = NULL;
struct hlist_head *head, empty_rp; struct hlist_head *head, empty_rp;
struct hlist_node *node, *tmp; struct hlist_node *tmp;
unsigned long flags, orig_ret_address = 0; unsigned long flags, orig_ret_address = 0;
unsigned long trampoline_address = (unsigned long)kretprobe_trampoline; unsigned long trampoline_address = (unsigned long)kretprobe_trampoline;


Expand All @@ -618,7 +618,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
* real return address, and all the rest will point to * real return address, and all the rest will point to
* kretprobe_trampoline * kretprobe_trampoline
*/ */
hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current) if (ri->task != current)
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
Expand All @@ -645,7 +645,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
kretprobe_hash_unlock(current, &flags); kretprobe_hash_unlock(current, &flags);
preempt_enable_no_resched(); preempt_enable_no_resched();


hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist); hlist_del(&ri->hlist);
kfree(ri); kfree(ri);
} }
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/kernel/kprobes.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
{ {
struct kretprobe_instance *ri = NULL; struct kretprobe_instance *ri = NULL;
struct hlist_head *head, empty_rp; struct hlist_head *head, empty_rp;
struct hlist_node *node, *tmp; struct hlist_node *tmp;
unsigned long flags, orig_ret_address = 0; unsigned long flags, orig_ret_address = 0;
unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline; unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline;


Expand All @@ -330,7 +330,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
* real return address, and all the rest will point to * real return address, and all the rest will point to
* kretprobe_trampoline * kretprobe_trampoline
*/ */
hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current) if (ri->task != current)
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
Expand All @@ -357,7 +357,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
kretprobe_hash_unlock(current, &flags); kretprobe_hash_unlock(current, &flags);
preempt_enable_no_resched(); preempt_enable_no_resched();


hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist); hlist_del(&ri->hlist);
kfree(ri); kfree(ri);
} }
Expand Down
18 changes: 6 additions & 12 deletions arch/powerpc/kvm/book3s_mmu_hpte.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -124,15 +124,14 @@ static void kvmppc_mmu_pte_flush_all(struct kvm_vcpu *vcpu)
{ {
struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
struct hpte_cache *pte; struct hpte_cache *pte;
struct hlist_node *node;
int i; int i;


rcu_read_lock(); rcu_read_lock();


for (i = 0; i < HPTEG_HASH_NUM_VPTE_LONG; i++) { for (i = 0; i < HPTEG_HASH_NUM_VPTE_LONG; i++) {
struct hlist_head *list = &vcpu3s->hpte_hash_vpte_long[i]; struct hlist_head *list = &vcpu3s->hpte_hash_vpte_long[i];


hlist_for_each_entry_rcu(pte, node, list, list_vpte_long) hlist_for_each_entry_rcu(pte, list, list_vpte_long)
invalidate_pte(vcpu, pte); invalidate_pte(vcpu, pte);
} }


Expand All @@ -143,7 +142,6 @@ static void kvmppc_mmu_pte_flush_page(struct kvm_vcpu *vcpu, ulong guest_ea)
{ {
struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
struct hlist_head *list; struct hlist_head *list;
struct hlist_node *node;
struct hpte_cache *pte; struct hpte_cache *pte;


/* Find the list of entries in the map */ /* Find the list of entries in the map */
Expand All @@ -152,7 +150,7 @@ static void kvmppc_mmu_pte_flush_page(struct kvm_vcpu *vcpu, ulong guest_ea)
rcu_read_lock(); rcu_read_lock();


/* Check the list for matching entries and invalidate */ /* Check the list for matching entries and invalidate */
hlist_for_each_entry_rcu(pte, node, list, list_pte) hlist_for_each_entry_rcu(pte, list, list_pte)
if ((pte->pte.eaddr & ~0xfffUL) == guest_ea) if ((pte->pte.eaddr & ~0xfffUL) == guest_ea)
invalidate_pte(vcpu, pte); invalidate_pte(vcpu, pte);


Expand All @@ -163,7 +161,6 @@ static void kvmppc_mmu_pte_flush_long(struct kvm_vcpu *vcpu, ulong guest_ea)
{ {
struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
struct hlist_head *list; struct hlist_head *list;
struct hlist_node *node;
struct hpte_cache *pte; struct hpte_cache *pte;


/* Find the list of entries in the map */ /* Find the list of entries in the map */
Expand All @@ -173,7 +170,7 @@ static void kvmppc_mmu_pte_flush_long(struct kvm_vcpu *vcpu, ulong guest_ea)
rcu_read_lock(); rcu_read_lock();


/* Check the list for matching entries and invalidate */ /* Check the list for matching entries and invalidate */
hlist_for_each_entry_rcu(pte, node, list, list_pte_long) hlist_for_each_entry_rcu(pte, list, list_pte_long)
if ((pte->pte.eaddr & 0x0ffff000UL) == guest_ea) if ((pte->pte.eaddr & 0x0ffff000UL) == guest_ea)
invalidate_pte(vcpu, pte); invalidate_pte(vcpu, pte);


Expand Down Expand Up @@ -207,7 +204,6 @@ static void kvmppc_mmu_pte_vflush_short(struct kvm_vcpu *vcpu, u64 guest_vp)
{ {
struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
struct hlist_head *list; struct hlist_head *list;
struct hlist_node *node;
struct hpte_cache *pte; struct hpte_cache *pte;
u64 vp_mask = 0xfffffffffULL; u64 vp_mask = 0xfffffffffULL;


Expand All @@ -216,7 +212,7 @@ static void kvmppc_mmu_pte_vflush_short(struct kvm_vcpu *vcpu, u64 guest_vp)
rcu_read_lock(); rcu_read_lock();


/* Check the list for matching entries and invalidate */ /* Check the list for matching entries and invalidate */
hlist_for_each_entry_rcu(pte, node, list, list_vpte) hlist_for_each_entry_rcu(pte, list, list_vpte)
if ((pte->pte.vpage & vp_mask) == guest_vp) if ((pte->pte.vpage & vp_mask) == guest_vp)
invalidate_pte(vcpu, pte); invalidate_pte(vcpu, pte);


Expand All @@ -228,7 +224,6 @@ static void kvmppc_mmu_pte_vflush_long(struct kvm_vcpu *vcpu, u64 guest_vp)
{ {
struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
struct hlist_head *list; struct hlist_head *list;
struct hlist_node *node;
struct hpte_cache *pte; struct hpte_cache *pte;
u64 vp_mask = 0xffffff000ULL; u64 vp_mask = 0xffffff000ULL;


Expand All @@ -238,7 +233,7 @@ static void kvmppc_mmu_pte_vflush_long(struct kvm_vcpu *vcpu, u64 guest_vp)
rcu_read_lock(); rcu_read_lock();


/* Check the list for matching entries and invalidate */ /* Check the list for matching entries and invalidate */
hlist_for_each_entry_rcu(pte, node, list, list_vpte_long) hlist_for_each_entry_rcu(pte, list, list_vpte_long)
if ((pte->pte.vpage & vp_mask) == guest_vp) if ((pte->pte.vpage & vp_mask) == guest_vp)
invalidate_pte(vcpu, pte); invalidate_pte(vcpu, pte);


Expand Down Expand Up @@ -266,7 +261,6 @@ void kvmppc_mmu_pte_vflush(struct kvm_vcpu *vcpu, u64 guest_vp, u64 vp_mask)
void kvmppc_mmu_pte_pflush(struct kvm_vcpu *vcpu, ulong pa_start, ulong pa_end) void kvmppc_mmu_pte_pflush(struct kvm_vcpu *vcpu, ulong pa_start, ulong pa_end)
{ {
struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
struct hlist_node *node;
struct hpte_cache *pte; struct hpte_cache *pte;
int i; int i;


Expand All @@ -277,7 +271,7 @@ void kvmppc_mmu_pte_pflush(struct kvm_vcpu *vcpu, ulong pa_start, ulong pa_end)
for (i = 0; i < HPTEG_HASH_NUM_VPTE_LONG; i++) { for (i = 0; i < HPTEG_HASH_NUM_VPTE_LONG; i++) {
struct hlist_head *list = &vcpu3s->hpte_hash_vpte_long[i]; struct hlist_head *list = &vcpu3s->hpte_hash_vpte_long[i];


hlist_for_each_entry_rcu(pte, node, list, list_vpte_long) hlist_for_each_entry_rcu(pte, list, list_vpte_long)
if ((pte->pte.raddr >= pa_start) && if ((pte->pte.raddr >= pa_start) &&
(pte->pte.raddr < pa_end)) (pte->pte.raddr < pa_end))
invalidate_pte(vcpu, pte); invalidate_pte(vcpu, pte);
Expand Down
8 changes: 4 additions & 4 deletions arch/s390/kernel/kprobes.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
{ {
struct kretprobe_instance *ri; struct kretprobe_instance *ri;
struct hlist_head *head, empty_rp; struct hlist_head *head, empty_rp;
struct hlist_node *node, *tmp; struct hlist_node *tmp;
unsigned long flags, orig_ret_address; unsigned long flags, orig_ret_address;
unsigned long trampoline_address; unsigned long trampoline_address;
kprobe_opcode_t *correct_ret_addr; kprobe_opcode_t *correct_ret_addr;
Expand All @@ -379,7 +379,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
orig_ret_address = 0; orig_ret_address = 0;
correct_ret_addr = NULL; correct_ret_addr = NULL;
trampoline_address = (unsigned long) &kretprobe_trampoline; trampoline_address = (unsigned long) &kretprobe_trampoline;
hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current) if (ri->task != current)
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
Expand All @@ -398,7 +398,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
kretprobe_assert(ri, orig_ret_address, trampoline_address); kretprobe_assert(ri, orig_ret_address, trampoline_address);


correct_ret_addr = ri->ret_addr; correct_ret_addr = ri->ret_addr;
hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current) if (ri->task != current)
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
Expand Down Expand Up @@ -427,7 +427,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
kretprobe_hash_unlock(current, &flags); kretprobe_hash_unlock(current, &flags);
preempt_enable_no_resched(); preempt_enable_no_resched();


hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist); hlist_del(&ri->hlist);
kfree(ri); kfree(ri);
} }
Expand Down
3 changes: 1 addition & 2 deletions arch/s390/pci/pci_msi.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ static DEFINE_SPINLOCK(msi_map_lock);


struct msi_desc *__irq_get_msi_desc(unsigned int irq) struct msi_desc *__irq_get_msi_desc(unsigned int irq)
{ {
struct hlist_node *entry;
struct msi_map *map; struct msi_map *map;


hlist_for_each_entry_rcu(map, entry, hlist_for_each_entry_rcu(map,
&msi_hash[msi_hashfn(irq)], msi_chain) &msi_hash[msi_hashfn(irq)], msi_chain)
if (map->irq == irq) if (map->irq == irq)
return map->msi; return map->msi;
Expand Down
6 changes: 3 additions & 3 deletions arch/sh/kernel/kprobes.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
{ {
struct kretprobe_instance *ri = NULL; struct kretprobe_instance *ri = NULL;
struct hlist_head *head, empty_rp; struct hlist_head *head, empty_rp;
struct hlist_node *node, *tmp; struct hlist_node *tmp;
unsigned long flags, orig_ret_address = 0; unsigned long flags, orig_ret_address = 0;
unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline; unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline;


Expand All @@ -330,7 +330,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
* real return address, and all the rest will point to * real return address, and all the rest will point to
* kretprobe_trampoline * kretprobe_trampoline
*/ */
hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current) if (ri->task != current)
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
Expand Down Expand Up @@ -360,7 +360,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)


preempt_enable_no_resched(); preempt_enable_no_resched();


hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist); hlist_del(&ri->hlist);
kfree(ri); kfree(ri);
} }
Expand Down
6 changes: 3 additions & 3 deletions arch/sparc/kernel/kprobes.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
{ {
struct kretprobe_instance *ri = NULL; struct kretprobe_instance *ri = NULL;
struct hlist_head *head, empty_rp; struct hlist_head *head, empty_rp;
struct hlist_node *node, *tmp; struct hlist_node *tmp;
unsigned long flags, orig_ret_address = 0; unsigned long flags, orig_ret_address = 0;
unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline; unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline;


Expand All @@ -531,7 +531,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
* real return address, and all the rest will point to * real return address, and all the rest will point to
* kretprobe_trampoline * kretprobe_trampoline
*/ */
hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current) if (ri->task != current)
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
Expand Down Expand Up @@ -559,7 +559,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
kretprobe_hash_unlock(current, &flags); kretprobe_hash_unlock(current, &flags);
preempt_enable_no_resched(); preempt_enable_no_resched();


hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist); hlist_del(&ri->hlist);
kfree(ri); kfree(ri);
} }
Expand Down
3 changes: 1 addition & 2 deletions arch/sparc/kernel/ldc.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -953,9 +953,8 @@ static HLIST_HEAD(ldc_channel_list);
static int __ldc_channel_exists(unsigned long id) static int __ldc_channel_exists(unsigned long id)
{ {
struct ldc_channel *lp; struct ldc_channel *lp;
struct hlist_node *n;


hlist_for_each_entry(lp, n, &ldc_channel_list, list) { hlist_for_each_entry(lp, &ldc_channel_list, list) {
if (lp->id == id) if (lp->id == id)
return 1; return 1;
} }
Expand Down
8 changes: 4 additions & 4 deletions arch/x86/kernel/kprobes/core.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
{ {
struct kretprobe_instance *ri = NULL; struct kretprobe_instance *ri = NULL;
struct hlist_head *head, empty_rp; struct hlist_head *head, empty_rp;
struct hlist_node *node, *tmp; struct hlist_node *tmp;
unsigned long flags, orig_ret_address = 0; unsigned long flags, orig_ret_address = 0;
unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline; unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline;
kprobe_opcode_t *correct_ret_addr = NULL; kprobe_opcode_t *correct_ret_addr = NULL;
Expand Down Expand Up @@ -682,7 +682,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
* will be the real return address, and all the rest will * will be the real return address, and all the rest will
* point to kretprobe_trampoline. * point to kretprobe_trampoline.
*/ */
hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current) if (ri->task != current)
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
Expand All @@ -701,7 +701,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
kretprobe_assert(ri, orig_ret_address, trampoline_address); kretprobe_assert(ri, orig_ret_address, trampoline_address);


correct_ret_addr = ri->ret_addr; correct_ret_addr = ri->ret_addr;
hlist_for_each_entry_safe(ri, node, tmp, head, hlist) { hlist_for_each_entry_safe(ri, tmp, head, hlist) {
if (ri->task != current) if (ri->task != current)
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
Expand All @@ -728,7 +728,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)


kretprobe_hash_unlock(current, &flags); kretprobe_hash_unlock(current, &flags);


hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist); hlist_del(&ri->hlist);
kfree(ri); kfree(ri);
} }
Expand Down
Loading

0 comments on commit b67bfe0

Please sign in to comment.