Commit de5c208d authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'linux-kselftest-fixes-5.19-rc4' of...

Merge tag 'linux-kselftest-fixes-5.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

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
parents 3abc3ae5 9b4d5c01
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
CFLAGS += -I../../../../usr/include/ CFLAGS += -I../../../../usr/include/
CFLAGS += -I../../../../include/
TEST_GEN_PROGS := dma_map_benchmark TEST_GEN_PROGS := dma_map_benchmark
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include <unistd.h> #include <unistd.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <linux/map_benchmark.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/map_benchmark.h>
#define NSEC_PER_MSEC 1000000L #define NSEC_PER_MSEC 1000000L
......
...@@ -7,10 +7,31 @@ else ifneq ($(filter -%,$(LLVM)),) ...@@ -7,10 +7,31 @@ else ifneq ($(filter -%,$(LLVM)),)
LLVM_SUFFIX := $(LLVM) LLVM_SUFFIX := $(LLVM)
endif endif
CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) CLANG_TARGET_FLAGS_arm := arm-linux-gnueabi
CLANG_TARGET_FLAGS_arm64 := aarch64-linux-gnu
CLANG_TARGET_FLAGS_hexagon := hexagon-linux-musl
CLANG_TARGET_FLAGS_m68k := m68k-linux-gnu
CLANG_TARGET_FLAGS_mips := mipsel-linux-gnu
CLANG_TARGET_FLAGS_powerpc := powerpc64le-linux-gnu
CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu
CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu
CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu
CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH))
ifeq ($(CROSS_COMPILE),)
ifeq ($(CLANG_TARGET_FLAGS),)
$(error Specify CROSS_COMPILE or add '--target=' option to lib.mk
else
CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS)
endif # CLANG_TARGET_FLAGS
else
CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
endif # CROSS_COMPILE
CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as
else else
CC := $(CROSS_COMPILE)gcc CC := $(CROSS_COMPILE)gcc
endif endif # LLVM
ifeq (0,$(MAKELEVEL)) ifeq (0,$(MAKELEVEL))
ifeq ($(OUTPUT),) ifeq ($(OUTPUT),)
......
...@@ -209,7 +209,7 @@ int main(int argc, char **argv) ...@@ -209,7 +209,7 @@ int main(int argc, char **argv)
if (write) if (write)
gup.gup_flags |= FOLL_WRITE; gup.gup_flags |= FOLL_WRITE;
gup_fd = open("/sys/kernel/debug/gup_test", O_RDWR); gup_fd = open(GUP_TEST_FILE, O_RDWR);
if (gup_fd == -1) { if (gup_fd == -1) {
switch (errno) { switch (errno) {
case EACCES: case EACCES:
...@@ -224,7 +224,7 @@ int main(int argc, char **argv) ...@@ -224,7 +224,7 @@ int main(int argc, char **argv)
printf("check if CONFIG_GUP_TEST is enabled in kernel config\n"); printf("check if CONFIG_GUP_TEST is enabled in kernel config\n");
break; break;
default: default:
perror("failed to open /sys/kernel/debug/gup_test"); perror("failed to open " GUP_TEST_FILE);
break; break;
} }
exit(KSFT_SKIP); exit(KSFT_SKIP);
......
...@@ -54,6 +54,7 @@ static int ksm_write_sysfs(const char *file_path, unsigned long val) ...@@ -54,6 +54,7 @@ static int ksm_write_sysfs(const char *file_path, unsigned long val)
} }
if (fprintf(f, "%lu", val) < 0) { if (fprintf(f, "%lu", val) < 0) {
perror("fprintf"); perror("fprintf");
fclose(f);
return 1; return 1;
} }
fclose(f); fclose(f);
...@@ -72,6 +73,7 @@ static int ksm_read_sysfs(const char *file_path, unsigned long *val) ...@@ -72,6 +73,7 @@ static int ksm_read_sysfs(const char *file_path, unsigned long *val)
} }
if (fscanf(f, "%lu", val) != 1) { if (fscanf(f, "%lu", val) != 1) {
perror("fscanf"); perror("fscanf");
fclose(f);
return 1; return 1;
} }
fclose(f); fclose(f);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment