Fixed possible NULL pointer dereference; thanks to Matthieu Bec.
--- a/master/master.c Mon Mar 10 13:43:48 2014 +0100
+++ b/master/master.c Mon May 05 13:49:45 2014 +0200
@@ -2651,6 +2651,7 @@
{
const ec_slave_t *slave;
unsigned int i;
+ int ret = 0;
if (down_interruptible(&master->master_sem)) {
return -EINTR;
@@ -2658,6 +2659,11 @@
slave = ec_master_find_slave_const(master, 0, slave_position);
+ if (slave == NULL) {
+ ret = -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;
@@ -2694,9 +2700,10 @@
slave_info->name[0] = 0;
}
+out_get_slave:
up(&master->master_sem);
- return 0;
+ return ret;
}
/*****************************************************************************/