[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220525105248.GA31002@duo.ucw.cz>
Date:   Wed, 25 May 2022 12:52:48 +0200
From:   Pavel Machek <pavel@...x.de>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        Zheng Yongjun <zhengyongjun3@...wei.com>,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Sasha Levin <sashal@...nel.org>
Subject: Re: [PATCH 4.14 04/33] Input: stmfts - fix reference leak in
 stmfts_input_open
Hi!
> From: Zheng Yongjun <zhengyongjun3@...wei.com>
> 
> [ Upstream commit 26623eea0da3476446909af96c980768df07bbd9 ]
> 
> pm_runtime_get_sync() will increment pm usage counter even it
> failed. Forgetting to call pm_runtime_put_noidle will result
> in reference leak in stmfts_input_open, so we should fix it.
This is wrong, AFAICT.
>  drivers/input/touchscreen/stmfts.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
> index d9e93dabbca2..9007027a7ad9 100644
> --- a/drivers/input/touchscreen/stmfts.c
> +++ b/drivers/input/touchscreen/stmfts.c
> @@ -344,11 +344,11 @@ static int stmfts_input_open(struct input_dev *dev)
>  
>  	err = pm_runtime_get_sync(&sdata->client->dev);
>  	if (err < 0)
> -		return err;
> +		goto out;
>  
>  	err = i2c_smbus_write_byte(sdata->client, STMFTS_MS_MT_SENSE_ON);
>  	if (err)
> -		return err;
> +		goto out;
>  
>  	mutex_lock(&sdata->mutex);
>  	sdata->running = true;
> @@ -371,7 +371,9 @@ static int stmfts_input_open(struct input_dev *dev)
>  				 "failed to enable touchkey\n");
>  	}
>  
> -	return 0;
> +out:
> +	pm_runtime_put_noidle(&sdata->client->dev);
> +	return err;
>  }
>  
>  static void stmfts_input_close(struct input_dev *dev)
We are now doing put even on the success path. That will break the
device... and will result in non-functional device and double put due
to the close path.
Best regards,
								Pavel
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists