mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 05:13:34 +08:00
orb: fix memory leaks, forgotten unlock & wrong exit condition in advertisement
How can someone just add a FIXME for such a simple case?!
This commit is contained in:
@@ -611,6 +611,7 @@ uORB::DeviceMaster::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
objname = strdup(meta->o_name);
|
objname = strdup(meta->o_name);
|
||||||
|
|
||||||
if (objname == nullptr) {
|
if (objname == nullptr) {
|
||||||
|
unlock();
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -618,6 +619,8 @@ uORB::DeviceMaster::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
devpath = strdup(nodepath);
|
devpath = strdup(nodepath);
|
||||||
|
|
||||||
if (devpath == nullptr) {
|
if (devpath == nullptr) {
|
||||||
|
unlock();
|
||||||
|
free((void *)objname);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,6 +630,8 @@ uORB::DeviceMaster::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
/* if we didn't get a device, that's bad */
|
/* if we didn't get a device, that's bad */
|
||||||
if (node == nullptr) {
|
if (node == nullptr) {
|
||||||
unlock();
|
unlock();
|
||||||
|
free((void *)objname);
|
||||||
|
free((void *)devpath);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,7 +669,7 @@ uORB::DeviceMaster::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
} while (ret != OK && (group_tries < max_group_tries));
|
} while (ret != OK && (group_tries < max_group_tries));
|
||||||
|
|
||||||
if (group_tries > max_group_tries) {
|
if (ret != PX4_OK && group_tries >= max_group_tries) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -617,6 +617,7 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
|
|||||||
objname = strdup(meta->o_name);
|
objname = strdup(meta->o_name);
|
||||||
|
|
||||||
if (objname == nullptr) {
|
if (objname == nullptr) {
|
||||||
|
unlock();
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,7 +625,8 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
|
|||||||
devpath = strdup(nodepath);
|
devpath = strdup(nodepath);
|
||||||
|
|
||||||
if (devpath == nullptr) {
|
if (devpath == nullptr) {
|
||||||
// FIXME - looks like we leaked memory here for objname
|
unlock();
|
||||||
|
free((void *)objname);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,8 +636,8 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
|
|||||||
/* if we didn't get a device, that's bad */
|
/* if we didn't get a device, that's bad */
|
||||||
if (node == nullptr) {
|
if (node == nullptr) {
|
||||||
unlock();
|
unlock();
|
||||||
|
free((void *)objname);
|
||||||
// FIXME - looks like we leaked memory here for devpath and objname
|
free((void *)devpath);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,7 +676,7 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
} while (ret != PX4_OK && (group_tries < max_group_tries));
|
} while (ret != PX4_OK && (group_tries < max_group_tries));
|
||||||
|
|
||||||
if (group_tries > max_group_tries) {
|
if (ret != PX4_OK && group_tries >= max_group_tries) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user