Skip to contentSkip to conversation

fbdev/xen-fbfront: Assign fb_info->device

PATCH Applied Jason Andryuk 6 participants 9 messages Sep 10, 2024 – Sep 11, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fbdev/xen-fbfront: Assign fb_info->device

From: Jason Andryuk <[email protected]>

Probing xen-fbfront faults in video_is_primary_device(). The passed-in struct device is NULL since xen-fbfront doesn't assign it and the memory is kzalloc()-ed. Assign fb_info->device to avoid this.

This was exposed by the conversion of fb_is_primary_device() to video_is_primary_device() which dropped a NULL check for struct device.

---
The other option would be to re-instate the NULL check in video_is_primary_device()

---
 drivers/video/fbdev/xen-fbfront.c | 1 +
 1 file changed, 1 insertion(+)
drivers/video/fbdev/xen-fbfront.c +1 -0
index 66d4628a96ae..c90f48ebb15e 100644
@@ -407,6 +407,7 @@ static int xenfb_probe(struct xenbus_device *dev,
 	/* complete the abuse: */
 	fb_info->pseudo_palette = fb_info->par;
 	fb_info->par = info;
+	fb_info->device = &dev->dev;
 
 	fb_info->screen_buffer = info->fb;
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Jason Andryuk

From: Jason Andryuk <[email protected]>

Probing xen-fbfront faults in video_is_primary_device(). The passed-in struct device is NULL since xen-fbfront doesn't assign it and the memory is kzalloc()-ed. Assign fb_info->device to avoid this.

This was exposed by the conversion of fb_is_primary_device() to video_is_primary_device() which dropped a NULL check for struct device.

Quoted 6 lines
Quoted 3 lines

---
The other option would be to re-instate the NULL check in video_is_primary_device()

I do think this is needed, or at least an explanation. The commit message in f178e96de7f0 doesn't mention anything about video_is_primary_device() not allowing being passed a NULL device (like it was possible with fb_is_primary_device()).

Otherwise callers of video_is_primary_device() would need to be adjusted to check for device != NULL.

Thanks, Roger.

Reviewed-by on v1 1/1
#7 lore raw
In reply to Jason Andryuk

Am 10.09.24 um 04:09 schrieb Jason Andryuk:

Quoted 9 lines

From: Jason Andryuk <[email protected]>

Probing xen-fbfront faults in video_is_primary_device(). The passed-in struct device is NULL since xen-fbfront doesn't assign it and the memory is kzalloc()-ed. Assign fb_info->device to avoid this.

This was exposed by the conversion of fb_is_primary_device() to video_is_primary_device() which dropped a NULL check for struct device.

Quoted 6 lines

Thanks a lot.

Quoted 19 lines

---
The other option would be to re-instate the NULL check in video_is_primary_device()

---
  drivers/video/fbdev/xen-fbfront.c | 1 +
  1 file changed, 1 insertion(+)
drivers/video/fbdev/xen-fbfront.c +1 -0
index 66d4628a96ae..c90f48ebb15e 100644
@@ -407,6 +407,7 @@ static int xenfb_probe(struct xenbus_device *dev,
  	/* complete the abuse: */
  	fb_info->pseudo_palette = fb_info->par;
  	fb_info->par = info;
+	fb_info->device = &dev->dev;
 
  	fb_info->screen_buffer = info->fb;
 
Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#2 lore raw
In reply to Roger Pau Monné

Hi

Am 10.09.24 um 09:22 schrieb Roger Pau Monné:

Quoted 21 lines · Jason Andryuk
Quoted 9 lines

From: Jason Andryuk <[email protected]>

Probing xen-fbfront faults in video_is_primary_device(). The passed-in struct device is NULL since xen-fbfront doesn't assign it and the memory is kzalloc()-ed. Assign fb_info->device to avoid this.

This was exposed by the conversion of fb_is_primary_device() to video_is_primary_device() which dropped a NULL check for struct device.

Quoted 6 lines
Quoted 3 lines

---
The other option would be to re-instate the NULL check in video_is_primary_device()

Quoted 7 lines

I do think this is needed, or at least an explanation. The commit message in f178e96de7f0 doesn't mention anything about video_is_primary_device() not allowing being passed a NULL device (like it was possible with fb_is_primary_device()).

Otherwise callers of video_is_primary_device() would need to be adjusted to check for device != NULL.

The helper expects a non-NULL pointer. We might want to document this.

Best regards
Thomas

Quoted 3 lines

Thanks, Roger.

Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#3 lore raw
Quoted 29 lines · Thomas Zimmermann

Hi

Am 10.09.24 um 09:22 schrieb Roger Pau Monné:

Quoted 26 lines · Jason Andryuk
Quoted 9 lines

From: Jason Andryuk <[email protected]>

Probing xen-fbfront faults in video_is_primary_device(). The passed-in struct device is NULL since xen-fbfront doesn't assign it and the memory is kzalloc()-ed. Assign fb_info->device to avoid this.

This was exposed by the conversion of fb_is_primary_device() to video_is_primary_device() which dropped a NULL check for struct device.

Quoted 6 lines
Quoted 3 lines

---
The other option would be to re-instate the NULL check in video_is_primary_device()

I do think this is needed, or at least an explanation. The commit message in f178e96de7f0 doesn't mention anything about video_is_primary_device() not allowing being passed a NULL device (like it was possible with fb_is_primary_device()).

Quoted 4 lines
Quoted 2 lines

Otherwise callers of video_is_primary_device() would need to be adjusted to check for device != NULL.

The helper expects a non-NULL pointer. We might want to document this.

A BUG_ON(!dev); might be enough documentation that the function expected a non-NULL dev IMO.

Thanks, Roger.

maintainer
#4 lore raw
Quoted 30 lines · Roger Pau Monné
Quoted 29 lines · Thomas Zimmermann

Hi

Am 10.09.24 um 09:22 schrieb Roger Pau Monné:

Quoted 26 lines · Jason Andryuk
Quoted 9 lines

From: Jason Andryuk <[email protected]>

Probing xen-fbfront faults in video_is_primary_device(). The passed-in struct device is NULL since xen-fbfront doesn't assign it and the memory is kzalloc()-ed. Assign fb_info->device to avoid this.

This was exposed by the conversion of fb_is_primary_device() to video_is_primary_device() which dropped a NULL check for struct device.

Quoted 6 lines
Quoted 3 lines

---
The other option would be to re-instate the NULL check in video_is_primary_device()

I do think this is needed, or at least an explanation. The commit message in f178e96de7f0 doesn't mention anything about video_is_primary_device() not allowing being passed a NULL device (like it was possible with fb_is_primary_device()).

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Otherwise callers of video_is_primary_device() would need to be adjusted to check for device != NULL.

The helper expects a non-NULL pointer. We might want to document this.

A BUG_ON(!dev); might be enough documentation that the function expected a non-NULL dev IMO.

No need for that, don't check for things that will never happen.

#5 lore raw
Quoted 35 lines · Greg KH
Quoted 33 lines · Roger Pau Monné
Quoted 32 lines · Thomas Zimmermann

Hi

Am 10.09.24 um 09:22 schrieb Roger Pau Monné:

Quoted 28 lines · Jason Andryuk
Quoted 9 lines

From: Jason Andryuk <[email protected]>

Probing xen-fbfront faults in video_is_primary_device(). The passed-in struct device is NULL since xen-fbfront doesn't assign it and the memory is kzalloc()-ed. Assign fb_info->device to avoid this.

This was exposed by the conversion of fb_is_primary_device() to video_is_primary_device() which dropped a NULL check for struct device.

Quoted 6 lines
Quoted 3 lines

---
The other option would be to re-instate the NULL check in video_is_primary_device()

I do think this is needed, or at least an explanation. The commit message in f178e96de7f0 doesn't mention anything about video_is_primary_device() not allowing being passed a NULL device (like it was possible with fb_is_primary_device()).

Otherwise callers of video_is_primary_device() would need to be adjusted to check for device != NULL.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

The helper expects a non-NULL pointer. We might want to document this.

A BUG_ON(!dev); might be enough documentation that the function expected a non-NULL dev IMO.

No need for that, don't check for things that will never happen.

And yet, here we are, me reporting a kernel/VM crash due to a thing that will never happen, see 'Closes' above.

I don't want to suggest BUG_ON is the right approach; I have no idea. I just want to mention that (!dev) did happen. :-)

maintainer
#6 lore raw
Quoted 41 lines · Arthur Borsboom
Quoted 40 lines · Greg KH
Quoted 37 lines · Roger Pau Monné
Quoted 29 lines · Thomas Zimmermann

Hi

Am 10.09.24 um 09:22 schrieb Roger Pau Monné:

Quoted 26 lines · Jason Andryuk
Quoted 9 lines

From: Jason Andryuk <[email protected]>

Probing xen-fbfront faults in video_is_primary_device(). The passed-in struct device is NULL since xen-fbfront doesn't assign it and the memory is kzalloc()-ed. Assign fb_info->device to avoid this.

This was exposed by the conversion of fb_is_primary_device() to video_is_primary_device() which dropped a NULL check for struct device.

Quoted 6 lines
Quoted 3 lines

---
The other option would be to re-instate the NULL check in video_is_primary_device()

I do think this is needed, or at least an explanation. The commit message in f178e96de7f0 doesn't mention anything about video_is_primary_device() not allowing being passed a NULL device (like it was possible with fb_is_primary_device()).

Quoted 4 lines
Quoted 2 lines

Otherwise callers of video_is_primary_device() would need to be adjusted to check for device != NULL.

The helper expects a non-NULL pointer. We might want to document this.

A BUG_ON(!dev); might be enough documentation that the function expected a non-NULL dev IMO.

Quoted 7 lines
Quoted 1 line

No need for that, don't check for things that will never happen.

And yet, here we are, me reporting a kernel/VM crash due to a thing that will never happen, see 'Closes' above.

I don't want to suggest BUG_ON is the right approach; I have no idea. I just want to mention that (!dev) did happen. :-)

A BUG_ON() will cause the same crash, so I don't see your point, sorry.

greg k-h

maintainer Applied
#8 lore raw
In reply to Jason Andryuk
Quoted 9 lines · Jason Andryuk

From: Jason Andryuk <[email protected]>

Probing xen-fbfront faults in video_is_primary_device(). The passed-in struct device is NULL since xen-fbfront doesn't assign it and the memory is kzalloc()-ed. Assign fb_info->device to avoid this.

This was exposed by the conversion of fb_is_primary_device() to video_is_primary_device() which dropped a NULL check for struct device.

Quoted 6 lines

applied to fbdev git tree.

Thanks!
Helge