Skip to content

Commit

Permalink
mcb: Fix an error handling path in 'chameleon_parse_cells()'
Browse files Browse the repository at this point in the history
If 'chameleon_get_bar()' fails, we will return 0, which mean success.
We should return the corresponding error code instead.

Remove the useless initialisation of 'ret' which was hiding the issue.
(if 'ret' is not set, gcc generates a warning ("warning: ‘ret’ may be used
uninitialized in this function"))

Signed-off-by: Christophe JAILLET <[email protected]>
Signed-off-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
tititiou36 authored and gregkh committed Aug 31, 2017
1 parent acf5e05 commit 5ec6bff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/mcb/mcb-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ int chameleon_parse_cells(struct mcb_bus *bus, phys_addr_t mapbase,
int num_cells = 0;
uint32_t dtype;
int bar_count;
int ret = 0;
int ret;
u32 hsize;

hsize = sizeof(struct chameleon_fpga_header);
Expand Down Expand Up @@ -210,8 +210,10 @@ int chameleon_parse_cells(struct mcb_bus *bus, phys_addr_t mapbase,
header->filename);

bar_count = chameleon_get_bar(&p, mapbase, &cb);
if (bar_count < 0)
if (bar_count < 0) {
ret = bar_count;
goto free_header;
}

for_each_chameleon_cell(dtype, p) {
switch (dtype) {
Expand Down

0 comments on commit 5ec6bff

Please sign in to comment.