git: a23e475c48da - main - lindebugfs: Make single_release() NULL safe.

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Fri, 11 Mar 2022 16:42:47 UTC
The branch main has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=a23e475c48da7a3751ffdc689be01d514ea2857c

commit a23e475c48da7a3751ffdc689be01d514ea2857c
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-03-11 16:39:44 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-03-11 16:41:33 +0000

    lindebugfs: Make single_release() NULL safe.
    
    MFC after:      1 week
    Sponsored by:   NVIDIA Networking
---
 sys/compat/linuxkpi/common/src/linux_seq_file.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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);