mbcs: add .owner to mbcs struct file_operations

This change “mbcs: add .owner to mbcs struct file_operations” in Linux kernel is authored by Naveen Kumar Parna <parna.naveenkumar [at] gmail.com> on Tue Jan 22 19:14:02 2019 +0530.

mbcs: add .owner to mbcs struct file_operations

Without ".owner = THIS_MODULE" it is possible to crash the kernel
by unloading the mbcs module while someone works with the file.
Fix this by initializing the ‘struct file_operations' ->owner with
THIS_MODULE.

Signed-off-by: Naveen Kumar Parna <parna.naveenkumar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

This Linux change may have been applied to various maintained Linux releases and you can find Linux releases including commit f9f7bb9.

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/char/mbcs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
index 8c9216a..0a31b60 100644
--- a/drivers/char/mbcs.c
+++ b/drivers/char/mbcs.c
@@ -50,6 +50,7 @@
  * file operations
  */
 static const struct file_operations mbcs_ops = {
+	.owner = THIS_MODULE,
 	.open = mbcs_open,
 	.llseek = mbcs_sram_llseek,
 	.read = mbcs_sram_read,

The commit for this change in Linux stable tree is f9f7bb9 (patch).

Leave a Reply

Your email address will not be published. Required fields are marked *