Skip to content

Commit 60b3a99

Browse files
cyndisthierryreding
authored andcommitted
firmware: tegra: bpmp: Fix error paths in debugfs
Some error paths in mrq_debug_read and bpmp_debug_show would overwrite the return error code with a subsequent call to mrq_debug_close. Change the code to only change the error code if there was no prior error. Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
1 parent fe15c26 commit 60b3a99

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/firmware/tegra/bpmp-debugfs.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static int mrq_debug_read(struct tegra_bpmp *bpmp, const char *name,
193193
},
194194
};
195195
u32 fd = 0, len = 0;
196-
int remaining, err;
196+
int remaining, err, close_err;
197197

198198
mutex_lock(&bpmp_debug_lock);
199199
err = mrq_debug_open(bpmp, name, &fd, &len, 0);
@@ -231,7 +231,9 @@ static int mrq_debug_read(struct tegra_bpmp *bpmp, const char *name,
231231
*nbytes = len;
232232

233233
close:
234-
err = mrq_debug_close(bpmp, fd);
234+
close_err = mrq_debug_close(bpmp, fd);
235+
if (!err)
236+
err = close_err;
235237
out:
236238
mutex_unlock(&bpmp_debug_lock);
237239
return err;
@@ -319,7 +321,7 @@ static int bpmp_debug_show(struct seq_file *m, void *p)
319321
},
320322
};
321323
u32 fd = 0, len = 0;
322-
int remaining, err;
324+
int remaining, err, close_err;
323325

324326
filename = get_filename(bpmp, file, fnamebuf, sizeof(fnamebuf));
325327
if (!filename)
@@ -353,7 +355,9 @@ static int bpmp_debug_show(struct seq_file *m, void *p)
353355
}
354356

355357
close:
356-
err = mrq_debug_close(bpmp, fd);
358+
close_err = mrq_debug_close(bpmp, fd);
359+
if (!err)
360+
err = close_err;
357361
out:
358362
mutex_unlock(&bpmp_debug_lock);
359363
return err;

0 commit comments

Comments
 (0)