diff options
| -rw-r--r-- | tools/perf/util/copyfile.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/perf/util/copyfile.c b/tools/perf/util/copyfile.c index 3fa0db136667..47e03de7c235 100644 --- a/tools/perf/util/copyfile.c +++ b/tools/perf/util/copyfile.c | |||
| @@ -101,14 +101,16 @@ static int copyfile_mode_ns(const char *from, const char *to, mode_t mode, | |||
| 101 | if (tofd < 0) | 101 | if (tofd < 0) |
| 102 | goto out; | 102 | goto out; |
| 103 | 103 | ||
| 104 | if (fchmod(tofd, mode)) | ||
| 105 | goto out_close_to; | ||
| 106 | |||
| 107 | if (st.st_size == 0) { /* /proc? do it slowly... */ | 104 | if (st.st_size == 0) { /* /proc? do it slowly... */ |
| 108 | err = slow_copyfile(from, tmp, nsi); | 105 | err = slow_copyfile(from, tmp, nsi); |
| 106 | if (!err && fchmod(tofd, mode)) | ||
| 107 | err = -1; | ||
| 109 | goto out_close_to; | 108 | goto out_close_to; |
| 110 | } | 109 | } |
| 111 | 110 | ||
| 111 | if (fchmod(tofd, mode)) | ||
| 112 | goto out_close_to; | ||
| 113 | |||
| 112 | nsinfo__mountns_enter(nsi, &nsc); | 114 | nsinfo__mountns_enter(nsi, &nsc); |
| 113 | fromfd = open(from, O_RDONLY); | 115 | fromfd = open(from, O_RDONLY); |
| 114 | nsinfo__mountns_exit(&nsc); | 116 | nsinfo__mountns_exit(&nsc); |
