Pull Kselftest fixes from Shuah Khan: "Compile time fixes and run-time resources leaks: - Fix clang cross compilation - Fix resource leak when return error - fix compile error for dma_map_benchmark - Fix regression - make use of GUP_TEST_FILE macro" * tag 'linux-kselftest-fixes-5.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: selftests: make use of GUP_TEST_FILE macro selftests: vm: Fix resource leak when return error selftests dma: fix compile error for dma_map_benchmark selftests: Fix clang cross compilation
Unified · Split
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | CFLAGS += -I../../../../usr/include/ |
| 3 | +CFLAGS += -I../../../../include/ | |
| 3 | 4 | |
| 4 | 5 | TEST_GEN_PROGS := dma_map_benchmark |
| 5 | 6 | |
| @@ -10,8 +10,8 @@ · 9 unmodified lines | ||
| 10 | 10 | #include <unistd.h> |
| 11 | 11 | #include <sys/ioctl.h> |
| 12 | 12 | #include <sys/mman.h> |
| 13 | −#include <linux/map_benchmark.h> | |
| 14 | 13 | #include <linux/types.h> |
| 14 | +#include <linux/map_benchmark.h> | |
| 15 | 15 | |
| 16 | 16 | #define NSEC_PER_MSEC 1000000L |
| 17 | 17 | |
| @@ -7,10 +7,31 @@ else ifneq ($(filter -%,$(LLVM)),) · 6 unmodified lines | ||
| 7 | 7 | LLVM_SUFFIX := $(LLVM) |
| 8 | 8 | endif |
| 9 | 9 | |
| 10 | −CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) | |
| 10 | +CLANG_TARGET_FLAGS_arm := arm-linux-gnueabi | |
| 11 | +CLANG_TARGET_FLAGS_arm64 := aarch64-linux-gnu | |
| 12 | +CLANG_TARGET_FLAGS_hexagon := hexagon-linux-musl | |
| 13 | +CLANG_TARGET_FLAGS_m68k := m68k-linux-gnu | |
| 14 | +CLANG_TARGET_FLAGS_mips := mipsel-linux-gnu | |
| 15 | +CLANG_TARGET_FLAGS_powerpc := powerpc64le-linux-gnu | |
| 16 | +CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu | |
| 17 | +CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu | |
| 18 | +CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu | |
| 19 | +CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH)) | |
| 20 | + | |
| 21 | +ifeq ($(CROSS_COMPILE),) | |
| 22 | +ifeq ($(CLANG_TARGET_FLAGS),) | |
| 23 | +$(error Specify CROSS_COMPILE or add '--target=' option to lib.mk | |
| 24 | +else | |
| 25 | +CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS) | |
| 26 | +endif # CLANG_TARGET_FLAGS | |
| 27 | +else | |
| 28 | +CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) | |
| 29 | +endif # CROSS_COMPILE | |
| 30 | + | |
| 31 | +CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as | |
| 11 | 32 | else |
| 12 | 33 | CC := $(CROSS_COMPILE)gcc |
| 13 | −endif | |
| 34 | +endif # LLVM | |
| 14 | 35 | |
| 15 | 36 | ifeq (0,$(MAKELEVEL)) |
| 16 | 37 | ifeq ($(OUTPUT),) |
| @@ -209,7 +209,7 @@ int main(int argc, char **argv) · 208 unmodified lines | ||
| 209 | 209 | if (write) |
| 210 | 210 | gup.gup_flags |= FOLL_WRITE; |
| 211 | 211 | |
| 212 | − gup_fd = open("/sys/kernel/debug/gup_test", O_RDWR); | |
| 212 | + gup_fd = open(GUP_TEST_FILE, O_RDWR); | |
| 213 | 213 | if (gup_fd == -1) { |
| 214 | 214 | switch (errno) { |
| 215 | 215 | case EACCES: |
| @@ -224,7 +224,7 @@ int main(int argc, char **argv) · 8 unmodified lines | ||
| 224 | 224 | printf("check if CONFIG_GUP_TEST is enabled in kernel config\n"); |
| 225 | 225 | break; |
| 226 | 226 | default: |
| 227 | − perror("failed to open /sys/kernel/debug/gup_test"); | |
| 227 | + perror("failed to open " GUP_TEST_FILE); | |
| 228 | 228 | break; |
| 229 | 229 | } |
| 230 | 230 | exit(KSFT_SKIP); |
| @@ -54,6 +54,7 @@ static int ksm_write_sysfs(const char *file_path, unsigned long val) · 53 unmodified lines | ||
| 54 | 54 | } |
| 55 | 55 | if (fprintf(f, "%lu", val) < 0) { |
| 56 | 56 | perror("fprintf"); |
| 57 | + fclose(f); | |
| 57 | 58 | return 1; |
| 58 | 59 | } |
| 59 | 60 | fclose(f); |
| @@ -72,6 +73,7 @@ static int ksm_read_sysfs(const char *file_path, unsigned long *val) · 12 unmodified lines | ||
| 72 | 73 | } |
| 73 | 74 | if (fscanf(f, "%lu", val) != 1) { |
| 74 | 75 | perror("fscanf"); |
| 76 | + fclose(f); | |
| 75 | 77 | return 1; |
| 76 | 78 | } |
| 77 | 79 | fclose(f); |