diff options
| -rw-r--r-- | tools/perf/util/dso.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 54bfe1f4762f..cbeecf683333 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
| @@ -250,8 +250,10 @@ bool dso__needs_decompress(struct dso *dso) | |||
| 250 | dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP; | 250 | dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP; |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf) | 253 | static int decompress_kmodule(struct dso *dso, const char *name, |
| 254 | char *pathname, size_t len) | ||
| 254 | { | 255 | { |
| 256 | char tmpbuf[] = KMOD_DECOMP_NAME; | ||
| 255 | int fd = -1; | 257 | int fd = -1; |
| 256 | 258 | ||
| 257 | if (!dso__needs_decompress(dso)) | 259 | if (!dso__needs_decompress(dso)) |
| @@ -272,34 +274,27 @@ static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf) | |||
| 272 | fd = -1; | 274 | fd = -1; |
| 273 | } | 275 | } |
| 274 | 276 | ||
| 277 | if (!pathname || (fd < 0)) | ||
| 278 | unlink(tmpbuf); | ||
| 279 | |||
| 280 | if (pathname && (fd >= 0)) | ||
| 281 | strncpy(pathname, tmpbuf, len); | ||
| 282 | |||
| 275 | return fd; | 283 | return fd; |
| 276 | } | 284 | } |
| 277 | 285 | ||
| 278 | int dso__decompress_kmodule_fd(struct dso *dso, const char *name) | 286 | int dso__decompress_kmodule_fd(struct dso *dso, const char *name) |
| 279 | { | 287 | { |
| 280 | char tmpbuf[] = KMOD_DECOMP_NAME; | 288 | return decompress_kmodule(dso, name, NULL, 0); |
| 281 | int fd; | ||
| 282 | |||
| 283 | fd = decompress_kmodule(dso, name, tmpbuf); | ||
| 284 | unlink(tmpbuf); | ||
| 285 | return fd; | ||
| 286 | } | 289 | } |
| 287 | 290 | ||
| 288 | int dso__decompress_kmodule_path(struct dso *dso, const char *name, | 291 | int dso__decompress_kmodule_path(struct dso *dso, const char *name, |
| 289 | char *pathname, size_t len) | 292 | char *pathname, size_t len) |
| 290 | { | 293 | { |
| 291 | char tmpbuf[] = KMOD_DECOMP_NAME; | 294 | int fd = decompress_kmodule(dso, name, pathname, len); |
| 292 | int fd; | ||
| 293 | |||
| 294 | fd = decompress_kmodule(dso, name, tmpbuf); | ||
| 295 | if (fd < 0) { | ||
| 296 | unlink(tmpbuf); | ||
| 297 | return -1; | ||
| 298 | } | ||
| 299 | 295 | ||
| 300 | strncpy(pathname, tmpbuf, len); | ||
| 301 | close(fd); | 296 | close(fd); |
| 302 | return 0; | 297 | return fd >= 0 ? 0 : -1; |
| 303 | } | 298 | } |
| 304 | 299 | ||
| 305 | /* | 300 | /* |
