Skip to content

Commit 0f9c726

Browse files
committed
Fix dereference NULL pointer with proc_lseek
Since the operations are static storage duration, the pointer in operation structures will initialize with NULL. But, the kernel doesn't check whether the pointer is NULL or not when calling it. Related Discussion: - #165 - #160 Close #165
1 parent c69eff9 commit 0f9c726

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

examples/sleep.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,15 @@ static const struct proc_ops file_ops_4_our_proc_file = {
169169
.proc_write = module_input, /* "write" to the file */
170170
.proc_open = module_open, /* called when the /proc file is opened */
171171
.proc_release = module_close, /* called when it's closed */
172+
.proc_lseek = noop_llseek, /* return file->f_pos */
172173
};
173174
#else
174175
static const struct file_operations file_ops_4_our_proc_file = {
175176
.read = module_output,
176177
.write = module_input,
177178
.open = module_open,
178179
.release = module_close,
180+
.llseek = noop_llseek,
179181
};
180182
#endif
181183

0 commit comments

Comments
 (0)