difos/target/linux/bcm27xx/patches-6.12/950-0811-media-i2c-arducam-pivariety-Fix-mutex-init-and-NULL-.patch
Álvaro Fernández Rojas 8f9e91ad03 bcm27xx: add 6.12 patches from RPi repo
These patches were generated from:
https://github.com/raspberrypi/linux/commits/rpi-6.12.y
With the following command:
git format-patch -N v6.12.27..HEAD
(HEAD -> 8d3206ee456a5ecdf9ddbfd8e5e231e4f0cd716e)

Exceptions:
- (def)configs patches
- github workflows patches
- applied & reverted patches
- readme patches
- wireless patches

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-05-21 11:32:18 +02:00

37 lines
1.1 KiB
Diff

From 5ec7749803e9f5c47188c5c8bdc883734f2c538d Mon Sep 17 00:00:00 2001
From: Yuriy Pasichnyk <yurijpasichnyk11@gmail.com>
Date: Tue, 18 Feb 2025 16:20:31 +0200
Subject: [PATCH] media: i2c: arducam-pivariety: Fix mutex init and NULL
pointer
The mutex used in arducam-pivariety was not properly initialized,
which could lead to undefined behavior. This also caused a NULL
pointer dereference under certain conditions.
This patch ensures the mutex is correctly initialized during probe
and prevents NULL pointer dereferences.
Signed-off-by: Yuriy Pasichnyk <yurijpasichnyk11@gmail.com>
---
drivers/media/i2c/arducam-pivariety.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/media/i2c/arducam-pivariety.c
+++ b/drivers/media/i2c/arducam-pivariety.c
@@ -1208,6 +1208,8 @@ static int pivariety_enum_controls(struc
if (ret)
return ret;
+ mutex_init(&pivariety->mutex);
+
index = 0;
while (1) {
ret = pivariety_write(pivariety, CTRL_INDEX_REG, index);
@@ -1295,6 +1297,7 @@ static int pivariety_enum_controls(struc
v4l2_ctrl_handler_setup(ctrl_hdlr);
return 0;
err:
+ mutex_destroy(&pivariety->mutex);
return -ENODEV;
}