Skip to contentSkip to conversation

pps: generators: tio: fix platform_set_drvdata()

PATCH Superseded Raag Jadav 4 participants 7 messages Mar 15, 2025 – Mar 17, 2025 PPS support

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

PATCH 1/1 pps: generators: tio: fix platform_set_drvdata()

Set driver_data correctly and fix illegal memory access on driver reload.

Fixes c89755d1111f ("pps: generators: Add PPS Generator TIO Driver")
---
 drivers/pps/generators/pps_gen_tio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pps/generators/pps_gen_tio.c +1 -1
index 6c46b46c66cd..6e4a383957d9 100644
@@ -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

Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Raag Jadav

Set driver_data correctly and fix illegal memory access on driver reload.

Fixes c89755d1111f ("pps: generators: Add PPS Generator TIO Driver")
Quoted 19 lines
---
  drivers/pps/generators/pps_gen_tio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pps/generators/pps_gen_tio.c +1 -1
index 6c46b46c66cd..6e4a383957d9 100644
@@ -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

Signature · 4 lines
GNU/Linux Solutions                  e-mail: [email protected]
Linux Device Driver                          [email protected]
Embedded Systems                     phone:  +39 349 2432127
UNIX programming
#2 lore raw
In reply to Raag Jadav
Quoted 1 line · Raag Jadav

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?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#3 lore raw
Quoted 4 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

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

#4 lore raw
Quoted 8 lines · Raag Jadav
Quoted 4 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
In reply to Raag Jadav
Quoted 13 lines · Raag Jadav

Set driver_data correctly and fix illegal memory access on driver reload.

Fixes c89755d1111f ("pps: generators: Add PPS Generator TIO Driver")
---
 drivers/pps/generators/pps_gen_tio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pps/generators/pps_gen_tio.c +0 -0
index 6c46b46c66cd..6e4a383957d9 100644

drivers/pps/generators/pps_gen_tio.c static int pps_gen_tio_probe(struct platform_device *pdev) · line 233

Quoted 5 lines
drivers/pps/generators/pps_gen_tio.c +1 -1
@@ -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

author
#6 lore raw
Quoted 9 lines · Greg KH
Quoted 8 lines · Raag Jadav

Set driver_data correctly and fix illegal memory access on driver reload.

Fixes c89755d1111f ("pps: generators: Add PPS Generator TIO Driver")
---
 drivers/pps/generators/pps_gen_tio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

drivers/pps/generators/pps_gen_tio.c static int pps_gen_tio_probe(struct platform_device *pdev) · line 233

Quoted 10 lines
drivers/pps/generators/pps_gen_tio.c +1 -1
index 6c46b46c66cd..6e4a383957d9 100644
@@ -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.

Quoted 2 lines

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