Merge branch 'dev' of 106.109.8.71:/srv/git/dbi into dev
authorYury Morozov <y.morozov@samsung.com>
Thu, 26 Jul 2012 08:35:09 +0000 (12:35 +0400)
committerYury Morozov <y.morozov@samsung.com>
Thu, 26 Jul 2012 08:35:09 +0000 (12:35 +0400)
1  2 
driver/us_proc_inst.c
driver/us_proc_inst.h

@@@ -1771,64 -1788,19 +1804,70 @@@ unsigned long get_ret_addr(struct task_
        struct hlist_node *item, *tmp_node;
        struct kretprobe_instance *ri;
  
-       hlist_for_each_safe (item, tmp_node, &ip->retprobe.used_instances) {
-               ri = hlist_entry (item, struct kretprobe_instance, uflist);
+       if (ip) {
+               hlist_for_each_safe (item, tmp_node, &ip->retprobe.used_instances) {
+                       ri = hlist_entry (item, struct kretprobe_instance, uflist);
  
-               if (ri->task->pid == current->pid)
-                       retaddr = (unsigned long)ri->ret_addr;
+                       if (ri->task && ri->task->pid == task->pid &&
+                                       ri->task->tgid == task->tgid)
+                               retaddr = (unsigned long)ri->ret_addr;
+               }
        }
  
-       return ((void *)retaddr);
+       if (retaddr)
+               return retaddr;
+       else
+               return dbi_get_ret_addr(task_pt_regs(task));
  }
  EXPORT_SYMBOL_GPL(get_ret_addr);
 +
 +/*function call removes all OTG-probes installed in library "lib_to_delete"*/
 +void otg_probe_list_clean(char* lib_to_delete)
 +{
 +      struct task_struct *task = current->group_leader;
 +      struct mm_struct *mm;
 +      struct vm_area_struct *vma = 0;
 +      char *filename = "";
 +      char *buf = "";
 +      unsigned long int addr_max = 0;
 +      unsigned long int addr_min = 0;
 +      int err;
 +      us_proc_otg_ip_t *p;
 +
 +      mm = task->active_mm;
 +/*find in process space map file with name "lib_to_delete" and flag VM_EXEC
 +and save address borders of this file*/
 +      if (mm) {
 +              vma = mm->mmap;
 +              while (vma) {
 +                      if(vma->vm_file) {
 +                              if(vma->vm_file->f_dentry) {
 +                                      struct path tmppath = {vma->vm_file->f_vfsmnt, vma->vm_file->f_dentry};
 +                                      filename = d_path(&vma->vm_file->f_path, buf, 256);
 +                                      if((strcmp(lib_to_delete, filename) == 0) && (vma->vm_flags & VM_EXEC)) {
 +                                              addr_min = vma->vm_start;
 +                                              addr_max = vma->vm_end;
 +                                              break;
 +                                      }
 +                              }
 +                      }
 +                      vma = vma->vm_next;
 +              }
 +      }
 +/*remove OTG-probe if its address is between addr_min and addr_max*/
 +      list_for_each_entry_rcu (p, &otg_us_proc_info, list) {
 +              if (!p->ip.installed) {
 +                      continue;
 +              }
 +              if ((p->ip.jprobe.kp.addr < addr_max)&&(p->ip.jprobe.kp.addr >= addr_min)) {
 +                      err = unregister_usprobe(task, &p->ip, 1);
 +                      if (err != 0) {
 +                              EPRINTF("failed to uninstall IP at %p. Error %d!",
 +                                       p->ip.jprobe.kp.addr, err);
 +                              continue;
 +                      }
 +                      p->ip.installed = 0;
 +              }
 +      }
 +}
 +EXPORT_SYMBOL_GPL(otg_probe_list_clean);
Simple merge