releasing of refcounted requests fixed: do not call EC_SLAVE_DBG without valid slave
authorMartin Troxler <ch1010277@ch10pc446>
Thu, 06 Jan 2011 12:47:20 +0100
changeset 2034 ca03a6737cb7
parent 2033 b67eb5c26716
child 2035 72a4e043e67d
releasing of refcounted requests fixed: do not call EC_SLAVE_DBG without valid slave
master/cdev.c
master/fsm_master.c
--- a/master/cdev.c	Thu Jan 06 10:50:54 2011 +0100
+++ b/master/cdev.c	Thu Jan 06 12:47:20 2011 +0100
@@ -864,9 +864,9 @@
     if (!(request->slave = ec_master_find_slave(
                     master, 0, data.slave_position))) {
         ec_mutex_unlock(&master->master_mutex);
-        kref_put(&request->refcount,ec_master_sdo_request_release);
         EC_MASTER_ERR(master, "Slave %u does not exist!\n",
                 data.slave_position);
+        kref_put(&request->refcount,ec_master_sdo_request_release);
         return -EINVAL;
     }
 
--- a/master/fsm_master.c	Thu Jan 06 10:50:54 2011 +0100
+++ b/master/fsm_master.c	Thu Jan 06 12:47:20 2011 +0100
@@ -1240,7 +1240,8 @@
 void ec_master_sii_write_request_release(struct kref *ref)
 {
     ec_sii_write_request_t *request = container_of(ref, ec_sii_write_request_t, refcount);
-    EC_SLAVE_DBG(request->slave, 1, "Releasing SII write request %p.\n",request);
+    if (request->slave)
+        EC_SLAVE_DBG(request->slave, 1, "Releasing SII write request %p.\n",request);
     kfree(request->words);
     kfree(request);
 }
@@ -1253,7 +1254,8 @@
 void ec_master_reg_request_release(struct kref *ref)
 {
     ec_reg_request_t *request = container_of(ref, ec_reg_request_t, refcount);
-    EC_SLAVE_DBG(request->slave, 1, "Releasing reg request %p.\n",request);
+    if (request->slave)
+        EC_SLAVE_DBG(request->slave, 1, "Releasing reg request %p.\n",request);
     if (request->data)
         kfree(request->data);
     kfree(request);
@@ -1267,7 +1269,8 @@
 void ec_master_sdo_request_release(struct kref *ref)
 {
     ec_master_sdo_request_t *request = container_of(ref, ec_master_sdo_request_t, refcount);
-    EC_SLAVE_DBG(request->slave, 1, "Releasing SDO request %p.\n",request);
+    if (request->slave)
+        EC_SLAVE_DBG(request->slave, 1, "Releasing SDO request %p.\n",request);
     ec_sdo_request_clear(&request->req);
     kfree(request);
 }
@@ -1280,7 +1283,8 @@
 void ec_master_foe_request_release(struct kref *ref)
 {
     ec_master_foe_request_t *request = container_of(ref, ec_master_foe_request_t, refcount);
-    EC_SLAVE_DBG(request->slave, 1, "Releasing FoE request %p.\n",request);
+    if (request->slave)
+        EC_SLAVE_DBG(request->slave, 1, "Releasing FoE request %p.\n",request);
     ec_foe_request_clear(&request->req);
     kfree(request);
 }
@@ -1293,7 +1297,8 @@
 void ec_master_soe_request_release(struct kref *ref)
 {
     ec_master_soe_request_t *request = container_of(ref, ec_master_soe_request_t, refcount);
-    EC_SLAVE_DBG(request->slave, 1, "Releasing SoE request %p.\n",request);
+    if (request->slave)
+        EC_SLAVE_DBG(request->slave, 1, "Releasing SoE request %p.\n",request);
     ec_soe_request_clear(&request->req);
     kfree(request);
 }