Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b7d25c3 authored by Christian Engelmayer's avatar Christian Engelmayer Committed by Thierry Reding
Browse files

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: default avatarChristian Engelmayer <cengelma@gmx.at>
Acked-by: default avatarMilo Kim <milo.kim@ti.com>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 38dbfb59
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -52,9 +52,11 @@ 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;
}