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

Commit 49ed411f authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

input: qcom-hv-haptics: Fix a possible NULL pointer dereference



Use Vmax from play effect in haptics_set_gain() only if the effect
is valid. Otherwise, use Vmax from the haptics configuration instead.

Change-Id: I7ec0f8c869096bccb26f7fda0057e3db3a51225d
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 0a4836e3
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1761,6 +1761,7 @@ static int haptics_erase(struct input_dev *dev, int effect_id)
static void haptics_set_gain(struct input_dev *dev, u16 gain)
{
	struct haptics_chip *chip = input_get_drvdata(dev);
	struct haptics_hw_config *config = &chip->config;
	struct haptics_play_info *play = &chip->play;
	u32 vmax_mv;

@@ -1770,7 +1771,10 @@ static void haptics_set_gain(struct input_dev *dev, u16 gain)
	if (gain > 0x7fff)
		gain = 0x7fff;

	vmax_mv = config->vmax_mv;
	if (play->effect)
		vmax_mv = play->effect->vmax_mv;

	if (chip->clamp_at_5v && (vmax_mv > CLAMPED_VMAX_MV))
		vmax_mv = CLAMPED_VMAX_MV;