[PATCH v1] pps: generators: tio: fix platform_set_drvdata()

Raag Jadav posted 1 patch 9 months, 1 week ago
There is a newer version of this series
drivers/pps/generators/pps_gen_tio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v1] pps: generators: tio: fix platform_set_drvdata()
Posted by Raag Jadav 9 months, 1 week ago
Set driver_data correctly and fix illegal memory access on driver reload.

Fixes: c89755d1111f ("pps: generators: Add PPS Generator TIO Driver")
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/pps/generators/pps_gen_tio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pps/generators/pps_gen_tio.c b/drivers/pps/generators/pps_gen_tio.c
index 6c46b46c66cd..6e4a383957d9 100644
--- a/drivers/pps/generators/pps_gen_tio.c
+++ b/drivers/pps/generators/pps_gen_tio.c
@@ -230,7 +230,7 @@ static int pps_gen_tio_probe(struct platform_device *pdev)
 	hrtimer_init(&tio->timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
 	tio->timer.function = hrtimer_callback;
 	spin_lock_init(&tio->lock);
-	platform_set_drvdata(pdev, &tio);
+	platform_set_drvdata(pdev, tio);
 
 	return 0;
 }

base-commit: 6f119e3da79ce5e586340059403ab77201c1bb45
-- 
2.34.1
Re: [PATCH v1] pps: generators: tio: fix platform_set_drvdata()
Posted by Greg KH 9 months ago
On Sat, Mar 15, 2025 at 07:01:40PM +0530, Raag Jadav wrote:
> Set driver_data correctly and fix illegal memory access on driver reload.
> 
> Fixes: c89755d1111f ("pps: generators: Add PPS Generator TIO Driver")
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> ---
>  drivers/pps/generators/pps_gen_tio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pps/generators/pps_gen_tio.c b/drivers/pps/generators/pps_gen_tio.c
> index 6c46b46c66cd..6e4a383957d9 100644
> --- a/drivers/pps/generators/pps_gen_tio.c
> +++ b/drivers/pps/generators/pps_gen_tio.c
> @@ -230,7 +230,7 @@ static int pps_gen_tio_probe(struct platform_device *pdev)
>  	hrtimer_init(&tio->timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
>  	tio->timer.function = hrtimer_callback;
>  	spin_lock_init(&tio->lock);
> -	platform_set_drvdata(pdev, &tio);
> +	platform_set_drvdata(pdev, tio);

What does reload have to do with this?  Either the data pointer is set
to the expected type or not, so that it can work properly, which has
nothing to do with when the device is unbound and then rebound (which is
what I think you mean by reload?)

So I think your changelog needs a lot of work here, as it's not really
explaining what is happening properly.

thanks,

greg k-h
Re: [PATCH v1] pps: generators: tio: fix platform_set_drvdata()
Posted by Raag Jadav 9 months ago
On Mon, Mar 17, 2025 at 08:32:29AM +0100, Greg KH wrote:
> On Sat, Mar 15, 2025 at 07:01:40PM +0530, Raag Jadav wrote:
> > Set driver_data correctly and fix illegal memory access on driver reload.
> > 
> > Fixes: c89755d1111f ("pps: generators: Add PPS Generator TIO Driver")
> > Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> > ---
> >  drivers/pps/generators/pps_gen_tio.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pps/generators/pps_gen_tio.c b/drivers/pps/generators/pps_gen_tio.c
> > index 6c46b46c66cd..6e4a383957d9 100644
> > --- a/drivers/pps/generators/pps_gen_tio.c
> > +++ b/drivers/pps/generators/pps_gen_tio.c
> > @@ -230,7 +230,7 @@ static int pps_gen_tio_probe(struct platform_device *pdev)
> >  	hrtimer_init(&tio->timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
> >  	tio->timer.function = hrtimer_callback;
> >  	spin_lock_init(&tio->lock);
> > -	platform_set_drvdata(pdev, &tio);
> > +	platform_set_drvdata(pdev, tio);
> 
> What does reload have to do with this?  Either the data pointer is set
> to the expected type or not, so that it can work properly, which has
> nothing to do with when the device is unbound and then rebound (which is
> what I think you mean by reload?)

->remove() is the only user of driver_data here.

> So I think your changelog needs a lot of work here, as it's not really
> explaining what is happening properly.

Sure, will update.

Raag
Re: [PATCH v1] pps: generators: tio: fix platform_set_drvdata()
Posted by Andy Shevchenko 9 months ago
On Sat, Mar 15, 2025 at 07:01:40PM +0530, Raag Jadav wrote:
> Set driver_data correctly and fix illegal memory access on driver reload.

Do you have it in practice or you are thinking it will be like this?

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v1] pps: generators: tio: fix platform_set_drvdata()
Posted by Raag Jadav 9 months ago
On Mon, Mar 17, 2025 at 09:26:59AM +0200, Andy Shevchenko wrote:
> On Sat, Mar 15, 2025 at 07:01:40PM +0530, Raag Jadav wrote:
> > Set driver_data correctly and fix illegal memory access on driver reload.
> 
> Do you have it in practice or you are thinking it will be like this?

I reproduced it but didn't want to bloat the commit message for an
obvious fix.

Raag
Re: [PATCH v1] pps: generators: tio: fix platform_set_drvdata()
Posted by Andy Shevchenko 9 months ago
On Mon, Mar 17, 2025 at 09:40:34AM +0200, Raag Jadav wrote:
> On Mon, Mar 17, 2025 at 09:26:59AM +0200, Andy Shevchenko wrote:
> > On Sat, Mar 15, 2025 at 07:01:40PM +0530, Raag Jadav wrote:
> > > Set driver_data correctly and fix illegal memory access on driver reload.
> > 
> > Do you have it in practice or you are thinking it will be like this?
> 
> I reproduced it but didn't want to bloat the commit message for an
> obvious fix.

Then add a few (~3-5) lines of the traceback and update commit message
to explain that this is a real case.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v1] pps: generators: tio: fix platform_set_drvdata()
Posted by Rodolfo Giometti 9 months ago
On 15/03/25 14:31, Raag Jadav wrote:
> Set driver_data correctly and fix illegal memory access on driver reload.
> 
> Fixes: c89755d1111f ("pps: generators: Add PPS Generator TIO Driver")
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>

Acked-by: Rodolfo Giometti <giometti@enneenne.com>

> ---
>   drivers/pps/generators/pps_gen_tio.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pps/generators/pps_gen_tio.c b/drivers/pps/generators/pps_gen_tio.c
> index 6c46b46c66cd..6e4a383957d9 100644
> --- a/drivers/pps/generators/pps_gen_tio.c
> +++ b/drivers/pps/generators/pps_gen_tio.c
> @@ -230,7 +230,7 @@ static int pps_gen_tio_probe(struct platform_device *pdev)
>   	hrtimer_init(&tio->timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
>   	tio->timer.function = hrtimer_callback;
>   	spin_lock_init(&tio->lock);
> -	platform_set_drvdata(pdev, &tio);
> +	platform_set_drvdata(pdev, tio);
>   
>   	return 0;
>   }
> 
> base-commit: 6f119e3da79ce5e586340059403ab77201c1bb45

-- 
GNU/Linux Solutions                  e-mail: giometti@enneenne.com
Linux Device Driver                          giometti@linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming