]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
media: v4l2-cci: Always assign *val
authorSakari Ailus <sakari.ailus@linux.intel.com>
Tue, 28 May 2024 11:00:51 +0000 (14:00 +0300)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Tue, 4 Jun 2024 06:31:25 +0000 (08:31 +0200)
Always assign *val to 0 in cci_read(). This has the benefit of not
requiring initialisation of the variables data is read to using
cci_read(). Once smatch is fixed, it could catch the use of uninitialised
reads.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/v4l2-core/v4l2-cci.c

index ee3475bed37fab2c370387efa3355522f3713a2e..1ff94affbaf3a362730f6b4632f3afd55360eae0 100644 (file)
@@ -23,6 +23,15 @@ int cci_read(struct regmap *map, u32 reg, u64 *val, int *err)
        u8 buf[8];
        int ret;
 
+       /*
+        * TODO: Fix smatch. Assign *val to 0 here in order to avoid
+        * failing a smatch check on caller when the caller proceeds to
+        * read *val without initialising it on caller's side. *val is set
+        * to a valid value whenever this function returns 0 but smatch
+        * can't figure that out currently.
+        */
+       *val = 0;
+
        if (err && *err)
                return *err;