Skip to contentSkip to conversation

media: ccs: Clean up parsed CCS static data on parse failure

PATCH Superseded Sakari Ailus 1 participant 1 message Dec 3, 2024

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Sakari Ailus

author maintainer
#0 lore raw

PATCH v2 1/1 media: ccs: Clean up parsed CCS static data on parse failure

ccs_data_parse() releases the allocated in-memory data structure when the parser fails, but it does not clean up parsed metadata that is there to help access the actual data. Do that, in order to return the data structure in a sane state.

Fixes a6b396f410b1 ("media: ccs: Add CCS static data parser library")

---
since v1:

- Add a necessary header and fix a typo.

 drivers/media/i2c/ccs/ccs-data.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/ccs/ccs-data.c +2 -0
index 9d42137f4799..0afdc73ead16 100644
@@ -10,6 +10,7 @@
 #include <linux/limits.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 
 #include "ccs-data-defs.h"
 
@@ -974,6 +975,7 @@ int ccs_data_parse(struct ccs_data_container *ccsdata, const void *data,
 
 out_free:
 	kvfree(bin.base);
+	memset(ccsdata, 0, sizeof(*ccsdata));
 
 	return rval;
 }
Signature · 1 line
2.39.5