Skip to content

Commit

Permalink
Soundwire: generic_bandwidth_allocation: don't free params if it is null
Browse files Browse the repository at this point in the history
We will free params when we goto out in sdw_compute_port_params(). But
we can't free params if it is not allocated successfully.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
  • Loading branch information
bardliao committed Aug 18, 2020
1 parent 706c576 commit 68e447d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/soundwire/generic_bandwidth_allocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ static int sdw_get_group_count(struct sdw_bus *bus,

} else {
ret = sdw_add_element_group_count(group, rate);
if (ret < 0)
if (ret < 0) {
kfree(group->rates);
return ret;
}
}
}

Expand All @@ -260,7 +262,7 @@ static int sdw_compute_port_params(struct sdw_bus *bus)

ret = sdw_get_group_count(bus, &group);
if (ret < 0)
goto out;
return ret;

if (group.count == 0)
goto out;
Expand All @@ -275,12 +277,13 @@ static int sdw_compute_port_params(struct sdw_bus *bus)
ret = sdw_compute_group_params(bus, params,
&group.rates[0], group.count);
if (ret < 0)
goto out;
goto free_params;

_sdw_compute_port_params(bus, params, group.count);

out:
free_params:
kfree(params);
out:
kfree(group.rates);

return ret;
Expand Down

0 comments on commit 68e447d

Please sign in to comment.