Skip to content

Commit

Permalink
radeon mkregtable: Add missing fclose() calls
Browse files Browse the repository at this point in the history
drivers/gpu/drm/radeon/mkregtable.c:parser_auth() almost always remembers
to fclose(file) before returning, but it misses two spots.

This is not really important since the process will exit shortly after and
thus close the file for us, but being explicit prevents static analysis
tools from complaining about leaked memory and missing fclose() calls and
it also seems to be the prefered style of the existing code to explicitly
close the file.

So, here's a patch to add the two missing fclose() calls.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Jesper Juhl authored and Dave Airlie committed Feb 13, 2011
1 parent c9417bd commit e917fd3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/gpu/drm/radeon/mkregtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,10 @@ static int parser_auth(struct table *t, const char *filename)
last_reg = strtol(last_reg_s, NULL, 16);

do {
if (fgets(buf, 1024, file) == NULL)
if (fgets(buf, 1024, file) == NULL) {
fclose(file);
return -1;
}
len = strlen(buf);
if (ftell(file) == end)
done = 1;
Expand All @@ -685,6 +687,7 @@ static int parser_auth(struct table *t, const char *filename)
fprintf(stderr,
"Error matching regular expression %d in %s\n",
r, filename);
fclose(file);
return -1;
} else {
buf[match[0].rm_eo] = 0;
Expand Down

0 comments on commit e917fd3

Please sign in to comment.