Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid memory access fixes #13203

Merged
merged 3 commits into from
Oct 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion platforms/nuttx/src/px4/nxp/kinetis/io_pins/io_timer.c
Original file line number Diff line number Diff line change
@@ -525,7 +525,7 @@ void io_timer_trigger(void)

irqstate_t flags = px4_enter_critical_section();

for (actions = 0; action_cache[actions] != 0 && actions < MAX_IO_TIMERS; actions++) {
for (actions = 0; actions < MAX_IO_TIMERS && action_cache[actions] != 0; actions++) {
_REG32(action_cache[actions], KINETIS_FTM_SYNC_OFFSET) |= FTM_SYNC;
}

Original file line number Diff line number Diff line change
@@ -559,7 +559,7 @@ void io_timer_trigger(void)

irqstate_t flags = px4_enter_critical_section();

for (actions = 0; action_cache[actions] != 0 && actions < MAX_IO_TIMERS; actions++) {
for (actions = 0; actions < MAX_IO_TIMERS && action_cache[actions] != 0; actions++) {
_REG32(action_cache[actions], STM32_GTIM_EGR_OFFSET) |= GTIM_EGR_UG;
}

4 changes: 4 additions & 0 deletions src/lib/mixer/mixer_helicopter.cpp
Original file line number Diff line number Diff line change
@@ -200,6 +200,10 @@ HelicopterMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handl
unsigned
HelicopterMixer::mix(float *outputs, unsigned space)
{
if (space < _mixer_info.control_count + 1u) {
return 0;
}

/* Find index to use for curves */
float thrust_cmd = get_control(0, 3);
int idx = (thrust_cmd / 0.25f);
4 changes: 4 additions & 0 deletions src/lib/mixer/mixer_multirotor.cpp
Original file line number Diff line number Diff line change
@@ -354,6 +354,10 @@ void MultirotorMixer::mix_yaw(float yaw, float *outputs)
unsigned
MultirotorMixer::mix(float *outputs, unsigned space)
{
if (space < _rotor_count) {
return 0;
}

float roll = math::constrain(get_control(0, 0) * _roll_scale, -1.0f, 1.0f);
float pitch = math::constrain(get_control(0, 1) * _pitch_scale, -1.0f, 1.0f);
float yaw = math::constrain(get_control(0, 2) * _yaw_scale, -1.0f, 1.0f);
2 changes: 1 addition & 1 deletion src/modules/uORB/uORBManager.cpp
Original file line number Diff line number Diff line change
@@ -198,7 +198,7 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta,
int fd = node_open(meta, true, instance, priority);

if (fd == PX4_ERROR) {
PX4_ERR("%s advertise failed", meta->o_name);
PX4_ERR("%s advertise failed (%i)", meta->o_name, errno);
return nullptr;
}