diff mbox series

media: i2c: thp7312: Fix missing unlock in return path

Message ID 20231128102222.9795-1-laurent.pinchart@ideasonboard.com (mailing list archive)
State New
Headers show
Series media: i2c: thp7312: Fix missing unlock in return path | expand

Commit Message

Laurent Pinchart Nov. 28, 2023, 10:22 a.m. UTC
One of the return paths in the thp7312_fw_write() function failed to
release a lock. Fix it.

Fixes: 29adc7a89b52 ("media: i2c: Add driver for THine THP7312")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Sakari, this patch fixes a bug in your master branch scheduled for v6.8.
Feel free to apply it on top or squash it with the commit that
introduced the bug based on what is the most convenient for you.
---
 drivers/media/i2c/thp7312.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)


base-commit: bdfbc0f7b7d2b8e9a2ddeb2da7f003c4f60da97e

Comments

Sakari Ailus Nov. 28, 2023, 10:24 a.m. UTC | #1
Hi Laurent,

On Tue, Nov 28, 2023 at 12:22:22PM +0200, Laurent Pinchart wrote:
> One of the return paths in the thp7312_fw_write() function failed to
> release a lock. Fix it.
> 
> Fixes: 29adc7a89b52 ("media: i2c: Add driver for THine THP7312")
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> Sakari, this patch fixes a bug in your master branch scheduled for v6.8.
> Feel free to apply it on top or squash it with the commit that
> introduced the bug based on what is the most convenient for you.
> ---
>  drivers/media/i2c/thp7312.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/thp7312.c b/drivers/media/i2c/thp7312.c
> index 04b78c1f8090..3d46e428e0ac 100644
> --- a/drivers/media/i2c/thp7312.c
> +++ b/drivers/media/i2c/thp7312.c
> @@ -1805,12 +1805,15 @@ static enum fw_upload_err thp7312_fw_write(struct fw_upload *fw_upload,
>  	struct device *dev = thp7312->dev;
>  	u16 header_size = size - THP7312_FW_RAM_SIZE;
>  	enum fw_upload_err ret;
> +	bool cancel;
>  
>  	mutex_lock(&thp7312->fw_lock);
> -	if (thp7312->fw_cancel)
> -		return FW_UPLOAD_ERR_CANCELED;
> +	cancel = thp7312->fw_cancel;
>  	mutex_unlock(&thp7312->fw_lock);
>  
> +	if (cancel)
> +		return FW_UPLOAD_ERR_CANCELED;
> +
>  	ret = thp7312_flash_erase(thp7312);
>  	if (ret != FW_UPLOAD_ERR_NONE)
>  		return ret;
> 

Thanks for the patch. I'm effectively forced to rebase the base and as I
haven't sent a PR, I'll just squash this.
diff mbox series

Patch

diff --git a/drivers/media/i2c/thp7312.c b/drivers/media/i2c/thp7312.c
index 04b78c1f8090..3d46e428e0ac 100644
--- a/drivers/media/i2c/thp7312.c
+++ b/drivers/media/i2c/thp7312.c
@@ -1805,12 +1805,15 @@  static enum fw_upload_err thp7312_fw_write(struct fw_upload *fw_upload,
 	struct device *dev = thp7312->dev;
 	u16 header_size = size - THP7312_FW_RAM_SIZE;
 	enum fw_upload_err ret;
+	bool cancel;
 
 	mutex_lock(&thp7312->fw_lock);
-	if (thp7312->fw_cancel)
-		return FW_UPLOAD_ERR_CANCELED;
+	cancel = thp7312->fw_cancel;
 	mutex_unlock(&thp7312->fw_lock);
 
+	if (cancel)
+		return FW_UPLOAD_ERR_CANCELED;
+
 	ret = thp7312_flash_erase(thp7312);
 	if (ret != FW_UPLOAD_ERR_NONE)
 		return ret;