git: d67b2c96153f - stable/13 - lindebugfs: Make single_release() NULL safe.

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Thu, 17 Mar 2022 10:00:19 UTC
The branch stable/13 has been updated by hselasky:

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

commit d67b2c96153fcef344648d907893b50e30817a38
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-17 09:55:12 +0000

    lindebugfs: Make single_release() NULL safe.
    
    Sponsored by:   NVIDIA Networking
    
    (cherry picked from commit a23e475c48da7a3751ffdc689be01d514ea2857c)
---
 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);