From: Colin King <hidden> Date: 2015-09-01 10:21:59
From: Colin Ian King <redacted>
On the unlikely event that drv is null, the current code will
perform a null pointer dereference with it when printing a dev_dbg
message. Instead, the BUG_ON check on drv should be performed
before we emit the dev_dbg message.
Signed-off-by: Colin Ian King <redacted>
---
drivers/ps3/ps3-vuart.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Hi Colin,
On Tue, Sep 1, 2015 at 12:21 PM, Colin King [off-list ref] wrote:
On the unlikely event that drv is null, the current code will
perform a null pointer dereference with it when printing a dev_dbg
message. Instead, the BUG_ON check on drv should be performed
before we emit the dev_dbg message.
What about just removing the BUG_ON()?
The system will crash anyway, providing a backtrace.
quoted hunk
Signed-off-by: Colin Ian King <redacted>
---
drivers/ps3/ps3-vuart.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
@@ -1000,12 +1000,11 @@ static int ps3_vuart_probe(struct ps3_system_bus_device *dev)dev_dbg(&dev->core,"%s:%d\n",__func__,__LINE__);drv=ps3_system_bus_dev_to_vuart_drv(dev);+BUG_ON(!drv);dev_dbg(&dev->core,"%s:%d: (%s)\n",__func__,__LINE__,drv->core.core.name);-BUG_ON(!drv);-if(dev->port_number>=PORT_COUNT){BUG();return-EINVAL;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
From: Colin Ian King <hidden> Date: 2015-09-01 10:39:32
On 01/09/15 11:35, Geert Uytterhoeven wrote:
Hi Colin,
On Tue, Sep 1, 2015 at 12:21 PM, Colin King [off-list ref] wrote:
quoted
On the unlikely event that drv is null, the current code will
perform a null pointer dereference with it when printing a dev_dbg
message. Instead, the BUG_ON check on drv should be performed
before we emit the dev_dbg message.
What about just removing the BUG_ON()?
The system will crash anyway, providing a backtrace.
I personally think a BUG_ON() shows intention to try to catch an
unexpected issue in a standard way as opposed to just removing it and
then hitting an issue with a null ptr deference.
quoted
Signed-off-by: Colin Ian King <redacted>
---
drivers/ps3/ps3-vuart.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
@@ -1000,12 +1000,11 @@ static int ps3_vuart_probe(struct ps3_system_bus_device *dev)dev_dbg(&dev->core,"%s:%d\n",__func__,__LINE__);drv=ps3_system_bus_dev_to_vuart_drv(dev);+BUG_ON(!drv);dev_dbg(&dev->core,"%s:%d: (%s)\n",__func__,__LINE__,drv->core.core.name);-BUG_ON(!drv);-if(dev->port_number>=PORT_COUNT){BUG();return-EINVAL;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Colin,
On Tue, Sep 1, 2015 at 12:38 PM, Colin Ian King
[off-list ref] wrote:
On 01/09/15 11:35, Geert Uytterhoeven wrote:
quoted
On Tue, Sep 1, 2015 at 12:21 PM, Colin King [off-list ref] wrote:
quoted
On the unlikely event that drv is null, the current code will
perform a null pointer dereference with it when printing a dev_dbg
message. Instead, the BUG_ON check on drv should be performed
before we emit the dev_dbg message.
What about just removing the BUG_ON()?
The system will crash anyway, providing a backtrace.
I personally think a BUG_ON() shows intention to try to catch an
unexpected issue in a standard way as opposed to just removing it and
then hitting an issue with a null ptr deference.
I think this BUG_ON() was purely used during development of the ps3_vuart
framework.
Note that the corresponding platform_drv_probe() also just dereferences its
driver pointer.
quoted
quoted
Signed-off-by: Colin Ian King <redacted>
---
drivers/ps3/ps3-vuart.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
@@ -1000,12 +1000,11 @@ static int ps3_vuart_probe(struct ps3_system_bus_device *dev)dev_dbg(&dev->core,"%s:%d\n",__func__,__LINE__);drv=ps3_system_bus_dev_to_vuart_drv(dev);+BUG_ON(!drv);dev_dbg(&dev->core,"%s:%d: (%s)\n",__func__,__LINE__,drv->core.core.name);-BUG_ON(!drv);-if(dev->port_number>=PORT_COUNT){BUG();return-EINVAL;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
On Tue, 2015-09-01 at 11:21 +0100, Colin King wrote:
On the unlikely event that drv is null, the current code will
perform a null pointer dereference with it when printing a dev_dbg
message. Instead, the BUG_ON check on drv should be performed
before we emit the dev_dbg message.
Signed-off-by: Colin Ian King <redacted>
I applied this to my ps3-linux repo. I can update it if you decide to
do the other fixes Geert mentioned.
-Geoff