[etherlab-dev] ecrt_master_get_slave BUG: unable to handle kernel NULL pointer dereference

matthieu bec mbec at gmto.org
Fri May 2 01:43:19 CEST 2014


Hello Florian,

ecrt_master_get_slave will receive a NULL pointer from 
ec_master_find_slave_const when the query doesn't succeed (e.g. a 
nonexistent slave_position) - but tries to fill the slave info response 
nonetheless, resulting in kernel BUG: unable to handle kernel NULL 
pointer dereference.

for your consideration, this patch addresses the issue:

hg diff  master/master.c
diff -r 2eff7c993a63 master/master.c
--- a/master/master.c	Tue Feb 12 17:31:08 2013 +0100
+++ b/master/master.c	Thu May 01 16:32:58 2014 -0700
@@ -2624,6 +2624,7 @@
  {
      const ec_slave_t *slave;
      unsigned int i;
+    int status = 0;

      if (down_interruptible(&master->master_sem)) {
          return -EINTR;
@@ -2631,6 +2632,11 @@

      slave = ec_master_find_slave_const(master, 0, slave_position);

+    if (slave == NULL) {
+       status = -ENOENT;
+       goto out_get_slave;
+    }
+
      slave_info->position = slave->ring_position;
      slave_info->vendor_id = slave->sii.vendor_id;
      slave_info->product_code = slave->sii.product_code;
@@ -2667,9 +2673,11 @@
          slave_info->name[0] = 0;
      }

+out_get_slave:
+
      up(&master->master_sem);

-    return 0;
+    return status;
  }

 
/*****************************************************************************/


Regards,
Matthieu



-- 
Matthieu Bec                GMTO Corp
cell : +1 626 354 9367      251 S Lake Ave, Suite 300
phone: +1 626 204 0527      Pasadena, CA 91101


More information about the etherlab-dev mailing list