Commit ae56e038 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

media: ccs: Make (non-)use of uninitialised variables more robust

GCC with W=2 level of kernel compiler warnings warns about the use of
uninitialised variables in a few locations. While these uninitialised
variables were not used in reality, this still produced compiler warnings.

Address this by assigning the variables to NULL and checking for NULL in
places it is not expected, returning -EIO in that case. This provides
at least some sanity checking at runtime as the compiler appears unable to
do that at compile time.
Reported-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 9db0fcde
...@@ -214,7 +214,7 @@ static int ccs_data_parse_regs(struct bin_container *bin, ...@@ -214,7 +214,7 @@ static int ccs_data_parse_regs(struct bin_container *bin,
size_t *__num_regs, const void *payload, size_t *__num_regs, const void *payload,
const void *endp, struct device *dev) const void *endp, struct device *dev)
{ {
struct ccs_reg *regs_base, *regs; struct ccs_reg *regs_base = NULL, *regs = NULL;
size_t num_regs = 0; size_t num_regs = 0;
u16 addr = 0; u16 addr = 0;
...@@ -285,6 +285,9 @@ static int ccs_data_parse_regs(struct bin_container *bin, ...@@ -285,6 +285,9 @@ static int ccs_data_parse_regs(struct bin_container *bin,
if (!bin->base) { if (!bin->base) {
bin_reserve(bin, len); bin_reserve(bin, len);
} else if (__regs) { } else if (__regs) {
if (!regs)
return -EIO;
regs->addr = addr; regs->addr = addr;
regs->len = len; regs->len = len;
regs->value = bin_alloc(bin, len); regs->value = bin_alloc(bin, len);
...@@ -305,8 +308,12 @@ static int ccs_data_parse_regs(struct bin_container *bin, ...@@ -305,8 +308,12 @@ static int ccs_data_parse_regs(struct bin_container *bin,
if (__num_regs) if (__num_regs)
*__num_regs = num_regs; *__num_regs = num_regs;
if (bin->base && __regs) if (bin->base && __regs) {
if (!regs_base)
return -EIO;
*__regs = regs_base; *__regs = regs_base;
}
return 0; return 0;
} }
...@@ -425,7 +432,7 @@ static int ccs_data_parse_rules(struct bin_container *bin, ...@@ -425,7 +432,7 @@ static int ccs_data_parse_rules(struct bin_container *bin,
size_t *__num_rules, const void *payload, size_t *__num_rules, const void *payload,
const void *endp, struct device *dev) const void *endp, struct device *dev)
{ {
struct ccs_rule *rules_base, *rules = NULL, *next_rule; struct ccs_rule *rules_base = NULL, *rules = NULL, *next_rule = NULL;
size_t num_rules = 0; size_t num_rules = 0;
const void *__next_rule = payload; const void *__next_rule = payload;
int rval; int rval;
...@@ -483,6 +490,9 @@ static int ccs_data_parse_rules(struct bin_container *bin, ...@@ -483,6 +490,9 @@ static int ccs_data_parse_rules(struct bin_container *bin,
} else { } else {
unsigned int i; unsigned int i;
if (!next_rule)
return -EIO;
rules = next_rule; rules = next_rule;
next_rule++; next_rule++;
...@@ -555,6 +565,9 @@ static int ccs_data_parse_rules(struct bin_container *bin, ...@@ -555,6 +565,9 @@ static int ccs_data_parse_rules(struct bin_container *bin,
bin_reserve(bin, sizeof(*rules) * num_rules); bin_reserve(bin, sizeof(*rules) * num_rules);
*__num_rules = num_rules; *__num_rules = num_rules;
} else { } else {
if (!rules_base)
return -EIO;
*__rules = rules_base; *__rules = rules_base;
} }
...@@ -690,7 +703,7 @@ static int ccs_data_parse_pdaf(struct bin_container *bin, struct ccs_pdaf_pix_lo ...@@ -690,7 +703,7 @@ static int ccs_data_parse_pdaf(struct bin_container *bin, struct ccs_pdaf_pix_lo
} }
for (i = 0; i < max_block_type_id; i++) { for (i = 0; i < max_block_type_id; i++) {
struct ccs_pdaf_pix_loc_pixel_desc_group *pdgroup; struct ccs_pdaf_pix_loc_pixel_desc_group *pdgroup = NULL;
unsigned int j; unsigned int j;
if (!is_contained(__num_pixel_descs, endp)) if (!is_contained(__num_pixel_descs, endp))
...@@ -721,6 +734,9 @@ static int ccs_data_parse_pdaf(struct bin_container *bin, struct ccs_pdaf_pix_lo ...@@ -721,6 +734,9 @@ static int ccs_data_parse_pdaf(struct bin_container *bin, struct ccs_pdaf_pix_lo
if (!bin->base) if (!bin->base)
continue; continue;
if (!pdgroup)
return -EIO;
pdesc = &pdgroup->descs[j]; pdesc = &pdgroup->descs[j];
pdesc->pixel_type = __pixel_desc->pixel_type; pdesc->pixel_type = __pixel_desc->pixel_type;
pdesc->small_offset_x = __pixel_desc->small_offset_x; pdesc->small_offset_x = __pixel_desc->small_offset_x;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment