Skip to content

Commit d0a45ee

Browse files
committed
Merge tag 'landlock-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux
Pull landlock updates from Mickaël Salaün: "One test fix and a __counted_by annotation" * tag 'landlock-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux: selftests/landlock: Fix a resource leak landlock: Annotate struct landlock_rule with __counted_by
2 parents a48fa7e + 2a20154 commit d0a45ee

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

security/landlock/ruleset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct landlock_rule {
6767
* @layers: Stack of layers, from the latest to the newest, implemented
6868
* as a flexible array member (FAM).
6969
*/
70-
struct landlock_layer layers[];
70+
struct landlock_layer layers[] __counted_by(num_layers);
7171
};
7272

7373
/**

tools/testing/selftests/landlock/fs_test.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static bool supports_filesystem(const char *const filesystem)
113113
{
114114
char str[32];
115115
int len;
116-
bool res;
116+
bool res = true;
117117
FILE *const inf = fopen("/proc/filesystems", "r");
118118

119119
/*
@@ -125,14 +125,16 @@ static bool supports_filesystem(const char *const filesystem)
125125

126126
/* filesystem can be null for bind mounts. */
127127
if (!filesystem)
128-
return true;
128+
goto out;
129129

130130
len = snprintf(str, sizeof(str), "nodev\t%s\n", filesystem);
131131
if (len >= sizeof(str))
132132
/* Ignores too-long filesystem names. */
133-
return true;
133+
goto out;
134134

135135
res = fgrep(inf, str);
136+
137+
out:
136138
fclose(inf);
137139
return res;
138140
}

0 commit comments

Comments
 (0)