aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2022-03-11 16:39:44 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2022-03-17 09:55:12 +0000
commitd67b2c96153fcef344648d907893b50e30817a38 (patch)
treeed78969d0f4d2a2a6ca267582a7ebb009f65fcd6
parenta16772a8111095a0358be9c046d321988f2696c2 (diff)
downloadsrc-d67b2c96153fcef344648d907893b50e30817a38.tar.gz
src-d67b2c96153fcef344648d907893b50e30817a38.zip
lindebugfs: Make single_release() NULL safe.
Sponsored by: NVIDIA Networking (cherry picked from commit a23e475c48da7a3751ffdc689be01d514ea2857c)
-rw-r--r--sys/compat/linuxkpi/common/src/linux_seq_file.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/compat/linuxkpi/common/src/linux_seq_file.c b/sys/compat/linuxkpi/common/src/linux_seq_file.c
index 6f4f1a368c4a..ed23bf8d010f 100644
--- a/sys/compat/linuxkpi/common/src/linux_seq_file.c
+++ b/sys/compat/linuxkpi/common/src/linux_seq_file.c
@@ -147,9 +147,15 @@ seq_release(struct inode *inode __unused, struct linux_file *file)
int
single_release(struct vnode *v, struct linux_file *f)
{
- const struct seq_operations *op = ((struct seq_file *)f->private_data)->op;
+ const struct seq_operations *op;
+ struct seq_file *m;
int rc;
+ /* be NULL safe */
+ if ((m = f->private_data) == NULL)
+ return (0);
+
+ op = m->op;
rc = seq_release(v, f);
free(__DECONST(void *, op), M_LSEQ);
return (rc);