Skip to contentSkip to conversation

pata_platform: Fix NULL pointer dereference

PATCH Applied Magnus Damm 5 participants 5 messages Jul 20, 2007 – Jul 21, 2007 libata

lore
Share & tools
lore
#0 lore raw

pata_platform: Fix NULL pointer dereference

pata_platform currently dereferences a NULL pointer in pata_platform_probe() if pdev->dev.platform_data is set to NULL. This breakage was most likely introduced by commit 5f45bc50976ee1f408f7171af155aec646655a37.

---

Tested on a Solution Engline 7722 board, fixes NULL dereference problem. Applies to linux-2.6 git 9a79b2274186fade17134929d4f85b70d59a3840 Could someone please make sure this gets included in rc1?

 drivers/ata/pata_platform.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/ata/pata_platform.c +3 -2
@@ -213,8 +213,9 @@ static int __devinit pata_platform_probe
 	pata_platform_setup_port(&ap->ioaddr, pp_info);
 
 	/* activate */
-	return ata_host_activate(host, platform_get_irq(pdev, 0), ata_interrupt,
-				 pp_info->irq_flags, &pata_platform_sht);
+	return ata_host_activate(host, platform_get_irq(pdev, 0),
+				 ata_interrupt, pp_info ? pp_info->irq_flags
+				 : 0, &pata_platform_sht);
 }
 
 /**
Acked-by
#1 lore raw
Quoted 7 lines · Magnus Damm

pata_platform: Fix NULL pointer dereference

pata_platform currently dereferences a NULL pointer in pata_platform_probe() if pdev->dev.platform_data is set to NULL. This breakage was most likely introduced by commit 5f45bc50976ee1f408f7171af155aec646655a37.

Without this, most of the sh and ppc pata_platform users won't boot.

Applied
#2 lore raw
In reply to Magnus Damm
Quoted 7 lines · Magnus Damm

pata_platform: Fix NULL pointer dereference

pata_platform currently dereferences a NULL pointer in pata_platform_probe() if pdev->dev.platform_data is set to NULL. This breakage was most likely introduced by commit 5f45bc50976ee1f408f7171af155aec646655a37.

Quoted 8 lines

---

Tested on a Solution Engline 7722 board, fixes NULL dereference problem. Applies to linux-2.6 git 9a79b2274186fade17134929d4f85b70d59a3840 Could someone please make sure this gets included in rc1?

 drivers/ata/pata_platform.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

applied

#3 lore raw
In reply to Magnus Damm
Quoted 4 lines · Magnus Damm

pata_platform currently dereferences a NULL pointer in pata_platform_probe() if pdev->dev.platform_data is set to NULL. This breakage was most likely introduced by commit 5f45bc50976ee1f408f7171af155aec646655a37.

Ok, the *fix* looks real enough, but it seems that you have done your line splitting with a word processor rather than with a source code editor:

drivers/ata/pata_platform.c static int __devinit pata_platform_probe · line 218

Quoted 3 lines
drivers/ata/pata_platform.c +3 -0
+	return ata_host_activate(host, platform_get_irq(pdev, 0),
+				 ata_interrupt, pp_info ? pp_info->irq_flags
+				 : 0, &pata_platform_sht);

Please don't do things like this. Splitting up expressions across two lines just to make the line length come out "right" is silly.

So do the

	"pp_info ? pp_info->irq_flags : 0"

expression on one line.

And if it means that the line is longe rthan 80 characters, then so be it. It's ok. It's still more readable than the alternative.

Linus "nit-picking bastard" Torvalds

#4 lore raw
Quoted 10 lines · Linus Torvalds

Ok, the *fix* looks real enough, but it seems that you have done your line splitting with a word processor rather than with a source code editor:

drivers/ata/pata_platform.c static int __devinit pata_platform_probe · line 218

Quoted 3 lines
drivers/ata/pata_platform.c +3 -0
+	return ata_host_activate(host, platform_get_irq(pdev, 0),
+				 ata_interrupt, pp_info ? pp_info->irq_flags
+				 : 0, &pata_platform_sht);

Please don't do things like this. Splitting up expressions across two lines just to make the line length come out "right" is silly.

Quoted 5 lines

So do the

	"pp_info ? pp_info->irq_flags : 0"

expression on one line.

Or just do

	return ata_host_activate(host, platform_get_irq(pdev, 0),
	       ata_interrupt, pp_info ? pp_info->irq_flags : 0,
	       &pata_platform_sht);

for returns, it's ok.

Jan