* [PATCH v1] fsi: Fix panic on scom file read
@ 2023-12-14 0:07 Lakshmi Yadlapati
2023-12-14 2:09 ` Ninad Palsule
0 siblings, 1 reply; 2+ messages in thread
From: Lakshmi Yadlapati @ 2023-12-14 0:07 UTC (permalink / raw)
To: joel, eajames, ninad, alistair; +Cc: Lakshmi Yadlapati, linux-fsi, linux-kernel
Reading the scom file without the custom open method (i2cr_scom_open)
causes a kernel panic. This change replaces simple_open with i2cr_scom_open
to properly initialize the private_data field in the file structure,
preventing the panic during scom file operations.
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
---
drivers/fsi/i2cr-scom.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/fsi/i2cr-scom.c b/drivers/fsi/i2cr-scom.c
index cb7e02213032..8d65c562b488 100644
--- a/drivers/fsi/i2cr-scom.c
+++ b/drivers/fsi/i2cr-scom.c
@@ -73,9 +73,18 @@ static ssize_t i2cr_scom_write(struct file *filep, const char __user *buf, size_
return len;
}
+static int i2cr_scom_open(struct inode *inode, struct file *file)
+{
+ struct i2cr_scom *scom = container_of(inode->i_cdev, struct i2cr_scom, cdev);
+
+ file->private_data = scom;
+
+ return 0;
+}
+
static const struct file_operations i2cr_scom_fops = {
.owner = THIS_MODULE,
- .open = simple_open,
+ .open = i2cr_scom_open,
.llseek = i2cr_scom_llseek,
.read = i2cr_scom_read,
.write = i2cr_scom_write,
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v1] fsi: Fix panic on scom file read
2023-12-14 0:07 [PATCH v1] fsi: Fix panic on scom file read Lakshmi Yadlapati
@ 2023-12-14 2:09 ` Ninad Palsule
0 siblings, 0 replies; 2+ messages in thread
From: Ninad Palsule @ 2023-12-14 2:09 UTC (permalink / raw)
To: Lakshmi Yadlapati, joel, eajames, alistair; +Cc: linux-fsi, linux-kernel
Hi Lakshmi,
On 12/13/23 18:07, Lakshmi Yadlapati wrote:
> Reading the scom file without the custom open method (i2cr_scom_open)
> causes a kernel panic. This change replaces simple_open with i2cr_scom_open
> to properly initialize the private_data field in the file structure,
> preventing the panic during scom file operations.
>
> Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
> ---
> drivers/fsi/i2cr-scom.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/fsi/i2cr-scom.c b/drivers/fsi/i2cr-scom.c
> index cb7e02213032..8d65c562b488 100644
> --- a/drivers/fsi/i2cr-scom.c
> +++ b/drivers/fsi/i2cr-scom.c
> @@ -73,9 +73,18 @@ static ssize_t i2cr_scom_write(struct file *filep, const char __user *buf, size_
> return len;
> }
>
> +static int i2cr_scom_open(struct inode *inode, struct file *file)
> +{
> + struct i2cr_scom *scom = container_of(inode->i_cdev, struct i2cr_scom, cdev);
> +
> + file->private_data = scom;
> +
> + return 0;
> +}
> +
> static const struct file_operations i2cr_scom_fops = {
> .owner = THIS_MODULE,
> - .open = simple_open,
> + .open = i2cr_scom_open,
> .llseek = i2cr_scom_llseek,
> .read = i2cr_scom_read,
> .write = i2cr_scom_write,
Looks good.
Reviewed-by: Ninad Palsule <ninad@linux.ibm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-14 2:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-14 0:07 [PATCH v1] fsi: Fix panic on scom file read Lakshmi Yadlapati
2023-12-14 2:09 ` Ninad Palsule
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®