pwm: lp3943: Fix potential memory leak during request
Fix a memory leak in the lp3943_pwm_request_map() error handling path. Make sure already allocated pwm map memory is freed correctly. Detected by Coverity: CID 1162829. Signed-off-by: Christian Engelmayer <cengelma@gmx.at> Acked-by: Milo Kim <milo.kim@ti.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
parent
38dbfb59d1
commit
0b7d25c347
1 changed files with 3 additions and 1 deletions
|
@ -52,8 +52,10 @@ lp3943_pwm_request_map(struct lp3943_pwm *lp3943_pwm, int hwpwm)
|
|||
offset = pwm_map->output[i];
|
||||
|
||||
/* Return an error if the pin is already assigned */
|
||||
if (test_and_set_bit(offset, &lp3943->pin_used))
|
||||
if (test_and_set_bit(offset, &lp3943->pin_used)) {
|
||||
kfree(pwm_map);
|
||||
return ERR_PTR(-EBUSY);
|
||||
}
|
||||
}
|
||||
|
||||
return pwm_map;
|
||||
|
|
Loading…
Reference in a new issue