public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* hpt366 ptr use before NULL check.
@ 2004-09-03 21:15 Dave Jones
  2004-09-03 21:53 ` Dave Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Jones @ 2004-09-03 21:15 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Alan Cox

Another picked up with the coverity checker.

Signed-off-by: Dave Jones <davej@redhat.com>

--- linux-2.6.8/drivers/ide/pci/hpt366.c~	2004-09-03 22:13:46.870500672 +0100
+++ linux-2.6.8/drivers/ide/pci/hpt366.c	2004-09-03 22:14:53.095432952 +0100
@@ -773,13 +773,17 @@
 static int hpt3xx_tristate (ide_drive_t * drive, int state)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct pci_dev *dev	= hwif->pci_dev;
-	u8 reg59h = 0, reset	= (hwif->channel) ? 0x80 : 0x40;
-	u8 regXXh = 0, state_reg= (hwif->channel) ? 0x57 : 0x53;
+	struct pci_dev *dev;
+	u8 reg59h = 0, reset;
+	u8 regXXh = 0, state_reg;
 
 	if (!hwif)
 		return -EINVAL;
 
+	dev = hwif->pci_dev;
+	reset = (hwif->channel) ? 0x80 : 0x40;
+	state_reg = (hwif->channel) ? 0x57 : 0x53;
+
 //	hwif->bus_state = state;
 
 	pci_read_config_byte(dev, 0x59, &reg59h);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: hpt366 ptr use before NULL check.
  2004-09-03 21:15 hpt366 ptr use before NULL check Dave Jones
@ 2004-09-03 21:53 ` Dave Jones
  2004-09-03 22:17   ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Jones @ 2004-09-03 21:53 UTC (permalink / raw)
  To: Linux Kernel, Alan Cox

On Fri, Sep 03, 2004 at 10:15:47PM +0100, Dave Jones wrote:
 > Another picked up with the coverity checker.
 > 
 > Signed-off-by: Dave Jones <davej@redhat.com>
 > 
 > --- linux-2.6.8/drivers/ide/pci/hpt366.c~	2004-09-03 22:13:46.870500672 +0100
 > +++ linux-2.6.8/drivers/ide/pci/hpt366.c	2004-09-03 22:14:53.095432952 +0100
 > @@ -773,13 +773,17 @@
 >  static int hpt3xx_tristate (ide_drive_t * drive, int state)
 >  {
 >  	ide_hwif_t *hwif	= HWIF(drive);
 > -	struct pci_dev *dev	= hwif->pci_dev;
 > -	u8 reg59h = 0, reset	= (hwif->channel) ? 0x80 : 0x40;
 > -	u8 regXXh = 0, state_reg= (hwif->channel) ? 0x57 : 0x53;
 > +	struct pci_dev *dev;
 > +	u8 reg59h = 0, reset;
 > +	u8 regXXh = 0, state_reg;
 >  
 >  	if (!hwif)
 >  		return -EINVAL;
 >  
 > +	dev = hwif->pci_dev;
 > +	reset = (hwif->channel) ? 0x80 : 0x40;
 > +	state_reg = (hwif->channel) ? 0x57 : 0x53;
 > +
 >  //	hwif->bus_state = state;
 >  
 >  	pci_read_config_byte(dev, 0x59, &reg59h);

Oops, missed one.

		Dave


--- linux-2.6.8/drivers/ide/pci/hpt366.c~	2004-09-03 22:15:56.848740976 +0100
+++ linux-2.6.8/drivers/ide/pci/hpt366.c	2004-09-03 22:16:33.470173672 +0100
@@ -813,13 +813,14 @@
 static int hpt370_busproc(ide_drive_t * drive, int state)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct pci_dev *dev	= hwif->pci_dev;
+	struct pci_dev *dev;
 	u8 tristate = 0, resetmask = 0, bus_reg = 0;
 	u16 tri_reg;
 
 	if (!hwif)
 		return -EINVAL;
 
+	dev = hwif->pci_dev;
 	hwif->bus_state = state;
 
 	if (hwif->channel) { 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: hpt366 ptr use before NULL check.
  2004-09-03 21:53 ` Dave Jones
@ 2004-09-03 22:17   ` Bartlomiej Zolnierkiewicz
  2004-09-03 22:28     ` Dave Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-09-03 22:17 UTC (permalink / raw)
  To: Dave Jones; +Cc: Linux Kernel, Alan Cox


bogus, hwif can't be NULL
please remove checks instead

On Friday 03 September 2004 23:53, Dave Jones wrote:
> On Fri, Sep 03, 2004 at 10:15:47PM +0100, Dave Jones wrote:
>  > Another picked up with the coverity checker.
>  > 
>  > Signed-off-by: Dave Jones <davej@redhat.com>
>  > 
>  > --- linux-2.6.8/drivers/ide/pci/hpt366.c~	2004-09-03 22:13:46.870500672 +0100
>  > +++ linux-2.6.8/drivers/ide/pci/hpt366.c	2004-09-03 22:14:53.095432952 +0100
>  > @@ -773,13 +773,17 @@
>  >  static int hpt3xx_tristate (ide_drive_t * drive, int state)
>  >  {
>  >  	ide_hwif_t *hwif	= HWIF(drive);
>  > -	struct pci_dev *dev	= hwif->pci_dev;
>  > -	u8 reg59h = 0, reset	= (hwif->channel) ? 0x80 : 0x40;
>  > -	u8 regXXh = 0, state_reg= (hwif->channel) ? 0x57 : 0x53;
>  > +	struct pci_dev *dev;
>  > +	u8 reg59h = 0, reset;
>  > +	u8 regXXh = 0, state_reg;
>  >  
>  >  	if (!hwif)
>  >  		return -EINVAL;
>  >  
>  > +	dev = hwif->pci_dev;
>  > +	reset = (hwif->channel) ? 0x80 : 0x40;
>  > +	state_reg = (hwif->channel) ? 0x57 : 0x53;
>  > +
>  >  //	hwif->bus_state = state;
>  >  
>  >  	pci_read_config_byte(dev, 0x59, &reg59h);
> 
> Oops, missed one.
> 
> 		Dave
> 
> 
> --- linux-2.6.8/drivers/ide/pci/hpt366.c~	2004-09-03 22:15:56.848740976 +0100
> +++ linux-2.6.8/drivers/ide/pci/hpt366.c	2004-09-03 22:16:33.470173672 +0100
> @@ -813,13 +813,14 @@
>  static int hpt370_busproc(ide_drive_t * drive, int state)
>  {
>  	ide_hwif_t *hwif	= HWIF(drive);
> -	struct pci_dev *dev	= hwif->pci_dev;
> +	struct pci_dev *dev;
>  	u8 tristate = 0, resetmask = 0, bus_reg = 0;
>  	u16 tri_reg;
>  
>  	if (!hwif)
>  		return -EINVAL;
>  
> +	dev = hwif->pci_dev;
>  	hwif->bus_state = state;
>  
>  	if (hwif->channel) { 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: hpt366 ptr use before NULL check.
  2004-09-03 22:17   ` Bartlomiej Zolnierkiewicz
@ 2004-09-03 22:28     ` Dave Jones
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Jones @ 2004-09-03 22:28 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Linux Kernel, Alan Cox

On Sat, Sep 04, 2004 at 12:17:07AM +0200, Bartlomiej Zolnierkiewicz wrote:
 > 
 > bogus, hwif can't be NULL
 > please remove checks instead


As you wish.


Signed-off-by: Dave Jones <davej@redhat.com>

--- latest-FC2/drivers/ide/pci/hpt366.c~	2004-09-03 23:26:29.092342152 +0100
+++ latest-FC2/drivers/ide/pci/hpt366.c	2004-09-03 23:27:28.249348920 +0100
@@ -777,9 +777,6 @@
 	u8 reg59h = 0, reset	= (hwif->channel) ? 0x80 : 0x40;
 	u8 regXXh = 0, state_reg= (hwif->channel) ? 0x57 : 0x53;
 
-	if (!hwif)
-		return -EINVAL;
-
 //	hwif->bus_state = state;
 
 	pci_read_config_byte(dev, 0x59, &reg59h);
@@ -813,9 +810,6 @@
 	u8 tristate = 0, resetmask = 0, bus_reg = 0;
 	u16 tri_reg;
 
-	if (!hwif)
-		return -EINVAL;
-
 	hwif->bus_state = state;
 
 	if (hwif->channel) { 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-09-03 22:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-03 21:15 hpt366 ptr use before NULL check Dave Jones
2004-09-03 21:53 ` Dave Jones
2004-09-03 22:17   ` Bartlomiej Zolnierkiewicz
2004-09-03 22:28     ` Dave Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox