[PATCH] media: pci: mg4b: fix uninitialized iio scan data

David Lechner posted 1 patch 2 months, 2 weeks ago
drivers/media/pci/mgb4/mgb4_trigger.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] media: pci: mg4b: fix uninitialized iio scan data
Posted by David Lechner 2 months, 2 weeks ago
Fix potential leak of uninitialized stack data to userspace by ensuring
that the `scan` structure is zeroed before use.

Fixes: 0ab13674a9bd ("media: pci: mgb4: Added Digiteq Automotive MGB4 driver")
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
 drivers/media/pci/mgb4/mgb4_trigger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/mgb4/mgb4_trigger.c b/drivers/media/pci/mgb4/mgb4_trigger.c
index 923650d53d4c82e87b542f87c3a0fbf6170dadc8..d7dddc5c8728e81c6249b03a4cbf692da15a4ced 100644
--- a/drivers/media/pci/mgb4/mgb4_trigger.c
+++ b/drivers/media/pci/mgb4/mgb4_trigger.c
@@ -91,7 +91,7 @@ static irqreturn_t trigger_handler(int irq, void *p)
 	struct {
 		u32 data;
 		s64 ts __aligned(8);
-	} scan;
+	} scan = { };
 
 	scan.data = mgb4_read_reg(&st->mgbdev->video, 0xA0);
 	mgb4_write_reg(&st->mgbdev->video, 0xA0, scan.data);

---
base-commit: cd2731444ee4e35db76f4fb587f12d327eec5446
change-id: 20250722-media-pci-mg4b-fix-uninitialized-iio-scan-data-2dce1574d1e9

Best regards,
-- 
David Lechner <dlechner@baylibre.com>
Re: [PATCH] media: pci: mg4b: fix uninitialized iio scan data
Posted by Jonathan Cameron 2 months, 1 week ago
On Tue, 22 Jul 2025 17:05:46 -0500
David Lechner <dlechner@baylibre.com> wrote:

> Fix potential leak of uninitialized stack data to userspace by ensuring
> that the `scan` structure is zeroed before use.
> 
> Fixes: 0ab13674a9bd ("media: pci: mgb4: Added Digiteq Automotive MGB4 driver")
> Signed-off-by: David Lechner <dlechner@baylibre.com>

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

> ---
>  drivers/media/pci/mgb4/mgb4_trigger.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/pci/mgb4/mgb4_trigger.c b/drivers/media/pci/mgb4/mgb4_trigger.c
> index 923650d53d4c82e87b542f87c3a0fbf6170dadc8..d7dddc5c8728e81c6249b03a4cbf692da15a4ced 100644
> --- a/drivers/media/pci/mgb4/mgb4_trigger.c
> +++ b/drivers/media/pci/mgb4/mgb4_trigger.c
> @@ -91,7 +91,7 @@ static irqreturn_t trigger_handler(int irq, void *p)
>  	struct {
>  		u32 data;
>  		s64 ts __aligned(8);

If you don't mind doing a follow up can change that to aligned_s64
and switch to iio_push_to_buffers_with_ts()

If not the second one at least will get swept up with other conversions
shortly and the aligned_s64 is just a nice to have.



> -	} scan;
> +	} scan = { };
>  
>  	scan.data = mgb4_read_reg(&st->mgbdev->video, 0xA0);
>  	mgb4_write_reg(&st->mgbdev->video, 0xA0, scan.data);
> 
> ---
> base-commit: cd2731444ee4e35db76f4fb587f12d327eec5446
> change-id: 20250722-media-pci-mg4b-fix-uninitialized-iio-scan-data-2dce1574d1e9
> 
> Best regards,