Skip to contentSkip to conversation

staging: comedi: ii_pci20kc: fix usage of uninit scalar in ii20k_attach()

PATCH Superseded Christian Engelmayer 3 participants 3 messages May 4, 2014 – May 23, 2014 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: comedi: ii_pci20kc: fix usage of uninit scalar in ii20k_attach()

This driver supports the PCI-20001C-1a and PCI-20001C-2a carrier boards. The -2a version has 32 on-board DIO channels. In case this variant is detected, local variable 'has_dio' is set accordingly. Otherwise it is left uninitialized and the following subdevice instantiation depends on the stack. Detected by Coverity - CID 1077830.

---
Compile tested and applies against branch staging-next of tree git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git

---
 drivers/staging/comedi/drivers/ii_pci20kc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/comedi/drivers/ii_pci20kc.c +1 -0
index 3558ab3..2516ce8 100644
@@ -461,6 +461,7 @@ static int ii20k_attach(struct comedi_device *dev,
 	id = readb(devpriv->ioaddr + II20K_ID_REG);
 	switch (id & II20K_ID_MASK) {
 	case II20K_ID_PCI20001C_1A:
+		has_dio = false;
 		break;
 	case II20K_ID_PCI20001C_2A:
 		has_dio = true;
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Christian Engelmayer

This driver supports the PCI-20001C-1a and PCI-20001C-2a carrier boards. The -2a version has 32 on-board DIO channels. In case this variant is detected, local variable 'has_dio' is set accordingly. Otherwise it is left uninitialized and the following subdevice instantiation depends on the stack. Detected by Coverity - CID 1077830.

---
Compile tested and applies against branch staging-next of tree git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git

---
  drivers/staging/comedi/drivers/ii_pci20kc.c | 1 +
  1 file changed, 1 insertion(+)
drivers/staging/comedi/drivers/ii_pci20kc.c +0 -0
index 3558ab3..2516ce8 100644

drivers/staging/comedi/drivers/ii_pci20kc.c static int ii20k_attach(struct comedi_device *dev, · line 467

Quoted 7 lines
drivers/staging/comedi/drivers/ii_pci20kc.c +1 -0
@@ -461,6 +461,7 @@ static int ii20k_attach(struct comedi_device *dev,
  	id = readb(devpriv->ioaddr + II20K_ID_REG);
  	switch (id & II20K_ID_MASK) {
  	case II20K_ID_PCI20001C_1A:
+		has_dio = false;
  		break;
  	case II20K_ID_PCI20001C_2A:
  		has_dio = true;

Thanks¬

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
maintainer
#2 lore raw
In reply to Christian Engelmayer
Quoted 11 lines · Christian Engelmayer

This driver supports the PCI-20001C-1a and PCI-20001C-2a carrier boards. The -2a version has 32 on-board DIO channels. In case this variant is detected, local variable 'has_dio' is set accordingly. Otherwise it is left uninitialized and the following subdevice instantiation depends on the stack. Detected by Coverity - CID 1077830.

---
Compile tested and applies against branch staging-next of tree git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git

It doesn't apply there at all for some odd reason, can you refresh it and resend?

thanks,

greg k-h