raw/cnxk_gpio: fix resource leak
All used resources need to be properly cleaned up in error path.
Fixes: 0e6557b448
("raw/cnxk_gpio: add self test")
Coverity issue: 376504
Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
This commit is contained in:
parent
4476bfdd79
commit
a8e1030905
@ -178,24 +178,30 @@ cnxk_gpio_parse_allowlist(struct cnxk_gpiochip *gpiochip)
|
||||
static int
|
||||
cnxk_gpio_read_attr(char *attr, char *val)
|
||||
{
|
||||
int ret, ret2;
|
||||
FILE *fp;
|
||||
int ret;
|
||||
|
||||
fp = fopen(attr, "r");
|
||||
if (!fp)
|
||||
return -errno;
|
||||
|
||||
ret = fscanf(fp, "%s", val);
|
||||
if (ret < 0)
|
||||
return -errno;
|
||||
if (ret != 1)
|
||||
return -EIO;
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
goto out;
|
||||
}
|
||||
if (ret != 1) {
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = fclose(fp);
|
||||
if (ret)
|
||||
return -errno;
|
||||
ret = 0;
|
||||
out:
|
||||
ret2 = fclose(fp);
|
||||
if (!ret)
|
||||
ret = ret2;
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user