Skip to content

Commit 6f716ac

Browse files
Christoph HellwigLinus Torvalds
authored andcommitted
kprobes: codingstyle cleanups
Remove superflous braces and fix indentation aswell as comments. Signed-off-by: Christoph Hellwig <[email protected]> Cc: Prasanna S Panchamukhi <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Anil S Keshavamurthy <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent b0bb501 commit 6f716ac

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

kernel/kprobes.c

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ kprobe_opcode_t __kprobes *get_insn_slot(void)
133133
struct kprobe_insn_page *kip;
134134
struct hlist_node *pos;
135135

136-
retry:
136+
retry:
137137
hlist_for_each_entry(kip, pos, &kprobe_insn_pages, hlist) {
138138
if (kip->nused < INSNS_PER_PAGE) {
139139
int i;
@@ -155,9 +155,8 @@ kprobe_opcode_t __kprobes *get_insn_slot(void)
155155
}
156156
/* All out of space. Need to allocate a new page. Use slot 0. */
157157
kip = kmalloc(sizeof(struct kprobe_insn_page), GFP_KERNEL);
158-
if (!kip) {
158+
if (!kip)
159159
return NULL;
160-
}
161160

162161
/*
163162
* Use module_alloc so this page is within +/- 2GB of where the
@@ -246,9 +245,9 @@ void __kprobes free_insn_slot(kprobe_opcode_t * slot, int dirty)
246245
break;
247246
}
248247
}
249-
if (dirty && (++kprobe_garbage_slots > INSNS_PER_PAGE)) {
248+
249+
if (dirty && ++kprobe_garbage_slots > INSNS_PER_PAGE)
250250
collect_garbage_slots();
251-
}
252251
}
253252
#endif
254253

@@ -314,7 +313,6 @@ static void __kprobes aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
314313
reset_kprobe_instance();
315314
}
316315
}
317-
return;
318316
}
319317

320318
static int __kprobes aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
@@ -533,8 +531,8 @@ static int __kprobes register_aggr_kprobe(struct kprobe *old_p,
533531

534532
static int __kprobes in_kprobes_functions(unsigned long addr)
535533
{
536-
if (addr >= (unsigned long)__kprobes_text_start
537-
&& addr < (unsigned long)__kprobes_text_end)
534+
if (addr >= (unsigned long)__kprobes_text_start &&
535+
addr < (unsigned long)__kprobes_text_end)
538536
return -EINVAL;
539537
return 0;
540538
}
@@ -561,19 +559,24 @@ static int __kprobes __register_kprobe(struct kprobe *p,
561559
return -EINVAL;
562560
p->addr = (kprobe_opcode_t *)(((char *)p->addr)+ p->offset);
563561

564-
if ((!kernel_text_address((unsigned long) p->addr)) ||
565-
in_kprobes_functions((unsigned long) p->addr))
562+
if (!kernel_text_address((unsigned long) p->addr) ||
563+
in_kprobes_functions((unsigned long) p->addr))
566564
return -EINVAL;
567565

568566
p->mod_refcounted = 0;
569-
/* Check are we probing a module */
570-
if ((probed_mod = module_text_address((unsigned long) p->addr))) {
567+
568+
/*
569+
* Check if are we probing a module.
570+
*/
571+
probed_mod = module_text_address((unsigned long) p->addr);
572+
if (probed_mod) {
571573
struct module *calling_mod = module_text_address(called_from);
572-
/* We must allow modules to probe themself and
573-
* in this case avoid incrementing the module refcount,
574-
* so as to allow unloading of self probing modules.
574+
/*
575+
* We must allow modules to probe themself and in this case
576+
* avoid incrementing the module refcount, so as to allow
577+
* unloading of self probing modules.
575578
*/
576-
if (calling_mod && (calling_mod != probed_mod)) {
579+
if (calling_mod && calling_mod != probed_mod) {
577580
if (unlikely(!try_module_get(probed_mod)))
578581
return -EINVAL;
579582
p->mod_refcounted = 1;
@@ -591,7 +594,8 @@ static int __kprobes __register_kprobe(struct kprobe *p,
591594
goto out;
592595
}
593596

594-
if ((ret = arch_prepare_kprobe(p)) != 0)
597+
ret = arch_prepare_kprobe(p);
598+
if (ret)
595599
goto out;
596600

597601
INIT_HLIST_NODE(&p->hlist);
@@ -614,8 +618,7 @@ static int __kprobes __register_kprobe(struct kprobe *p,
614618

615619
int __kprobes register_kprobe(struct kprobe *p)
616620
{
617-
return __register_kprobe(p,
618-
(unsigned long)__builtin_return_address(0));
621+
return __register_kprobe(p, (unsigned long)__builtin_return_address(0));
619622
}
620623

621624
void __kprobes unregister_kprobe(struct kprobe *p)
@@ -639,9 +642,9 @@ void __kprobes unregister_kprobe(struct kprobe *p)
639642
return;
640643
}
641644
valid_p:
642-
if ((old_p == p) || ((old_p->pre_handler == aggr_pre_handler) &&
643-
(p->list.next == &old_p->list) &&
644-
(p->list.prev == &old_p->list))) {
645+
if (old_p == p ||
646+
(old_p->pre_handler == aggr_pre_handler &&
647+
p->list.next == &old_p->list && p->list.prev == &old_p->list)) {
645648
/* Only probe on the hash list */
646649
arch_disarm_kprobe(p);
647650
hlist_del_rcu(&old_p->hlist);
@@ -654,9 +657,11 @@ void __kprobes unregister_kprobe(struct kprobe *p)
654657
mutex_unlock(&kprobe_mutex);
655658

656659
synchronize_sched();
657-
if (p->mod_refcounted &&
658-
(mod = module_text_address((unsigned long)p->addr)))
659-
module_put(mod);
660+
if (p->mod_refcounted) {
661+
mod = module_text_address((unsigned long)p->addr);
662+
if (mod)
663+
module_put(mod);
664+
}
660665

661666
if (cleanup_p) {
662667
if (p != old_p) {

0 commit comments

Comments
 (0)