UPSTREAM: 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.

Bug 3980003

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I3b2ce03c19aed2f6c692f69f68d8ce18c3e6c53a
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2871549
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Timo Alho <talho@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Mikko Perttunen
2023-03-01 14:37:19 +02:00
committed by mobile promotions
parent b2f8da0be3
commit c711393bdf

View File

@@ -198,7 +198,7 @@ static int mrq_debug_read(struct tegra_bpmp *bpmp, const char *name,
}, },
}; };
u32 fd = 0, len = 0; u32 fd = 0, len = 0;
int remaining, err; int remaining, err, close_err;
mutex_lock(&bpmp_debug_lock); mutex_lock(&bpmp_debug_lock);
err = mrq_debug_open(bpmp, name, &fd, &len, 0); err = mrq_debug_open(bpmp, name, &fd, &len, 0);
@@ -236,7 +236,9 @@ static int mrq_debug_read(struct tegra_bpmp *bpmp, const char *name,
*nbytes = len; *nbytes = len;
close: close:
err = mrq_debug_close(bpmp, fd); close_err = mrq_debug_close(bpmp, fd);
if (!err)
err = close_err;
out: out:
mutex_unlock(&bpmp_debug_lock); mutex_unlock(&bpmp_debug_lock);
return err; return err;
@@ -324,7 +326,7 @@ static int bpmp_debug_show(struct seq_file *m, void *p)
}, },
}; };
u32 fd = 0, len = 0; u32 fd = 0, len = 0;
int remaining, err; int remaining, err, close_err;
filename = get_filename(bpmp, file, fnamebuf, sizeof(fnamebuf)); filename = get_filename(bpmp, file, fnamebuf, sizeof(fnamebuf));
if (!filename) if (!filename)
@@ -358,7 +360,9 @@ static int bpmp_debug_show(struct seq_file *m, void *p)
} }
close: close:
err = mrq_debug_close(bpmp, fd); close_err = mrq_debug_close(bpmp, fd);
if (!err)
err = close_err;
out: out:
mutex_unlock(&bpmp_debug_lock); mutex_unlock(&bpmp_debug_lock);
return err; return err;