Skip to contentSkip to conversation

staging: sm7xxfb: copy name of the device before calling smtc_alloc_fb_info

PATCH Superseded Devendra Naga 2 participants 4 messages Aug 4, 2012 – Aug 6, 2012 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: sm7xxfb: copy name of the device before calling smtc_alloc_fb_info

as we do a strcpy(smdrv_ptr->fb_struct->fix->id, name), and the name here in sm7xxx_probe is not having any assignment, and which leads to copying of the garbage value into the id field of the fix struct of fb interface struct. fix it by copying the name before calling alloc_fbinfo

---
Only compile tested
This patch is not tested using the hardware... if any one is having this hardware, i request them to
please test this

 drivers/staging/sm7xxfb/sm7xxfb.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/sm7xxfb/sm7xxfb.c +4 -3
index 1c1780c..d3957ef 100644
@@ -798,16 +798,17 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
 	if (err)
 		return err;
 
+	sprintf(name, "sm%Xfb", ent->device);
+
 	sfb = smtc_alloc_fb_info(pdev, name);
 
+	sfb->chip_id = ent->device;
+
 	if (!sfb) {
 		err = -ENOMEM;
 		goto failed_free;
 	}
 
-	sfb->chip_id = ent->device;
-	sprintf(name, "sm%Xfb", sfb->chip_id);
-
 	pci_set_drvdata(pdev, sfb);
 
 	sm7xx_init_hw();
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 18 lines · Devendra Naga

as we do a strcpy(smdrv_ptr->fb_struct->fix->id, name), and the name here in sm7xxx_probe is not having any assignment, and which leads to copying of the garbage value into the id field of the fix struct of fb interface struct. fix it by copying the name before calling alloc_fbinfo

---
Only compile tested
This patch is not tested using the hardware... if any one is having this hardware, i request them to
please test this

 drivers/staging/sm7xxfb/sm7xxfb.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/sm7xxfb/sm7xxfb.c +0 -0
index 1c1780c..d3957ef 100644

drivers/staging/sm7xxfb/sm7xxfb.c static int __devinit smtcfb_pci_probe(struct pci_dev *pdev, · line 807

Quoted 10 lines
drivers/staging/sm7xxfb/sm7xxfb.c +4 -0
@@ -798,16 +798,17 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
 	if (err)
 		return err;
 
+	sprintf(name, "sm%Xfb", ent->device);
+
 	sfb = smtc_alloc_fb_info(pdev, name);
 
+	sfb->chip_id = ent->device;
+
 	if (!sfb) {

Thanks for fixing this, and well done for spotting the bug.

There is a dereference before the check here, but I see you resent this in another thread. Next time could you respond to the original with a message which says to not apply it.

regards,
dan carpenter

#2 lore raw
Quoted 26 lines · Dan Carpenter
Quoted 25 lines · Devendra Naga

as we do a strcpy(smdrv_ptr->fb_struct->fix->id, name), and the name here in sm7xxx_probe is not having any assignment, and which leads to copying of the garbage value into the id field of the fix struct of fb interface struct. fix it by copying the name before calling alloc_fbinfo

---
Only compile tested
This patch is not tested using the hardware... if any one is having this hardware, i request them to
please test this

 drivers/staging/sm7xxfb/sm7xxfb.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/sm7xxfb/sm7xxfb.c +2 -0
index 1c1780c..d3957ef 100644
@@ -798,16 +798,17 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
      if (err)
              return err;
 
+     sprintf(name, "sm%Xfb", ent->device);
+
      sfb = smtc_alloc_fb_info(pdev, name);
 
Quoted 6 lines

drivers/staging/sm7xxfb/sm7xxfb.c static int __devinit smtcfb_pci_probe(struct pci_dev *pdev, · line 807

Quoted 3 lines
drivers/staging/sm7xxfb/sm7xxfb.c +2 -0
+     sfb->chip_id = ent->device;
+
      if (!sfb) {

Thanks for fixing this, and well done for spotting the bug.

Thanks Dan...

Quoted 4 lines

There is a dereference before the check here, but I see you resent this in another thread. Next time could you respond to the original with a message which says to not apply it.

Sure but i have a doubt.

since we do V++ after every change to the sent patch , do we really need to say that please dont apply this patch and there's one more patch coming with fix?

Quoted 4 lines

regards,
dan carpenter

Thanks,

#3 lore raw
Quoted 39 lines · Devendra Naga
Quoted 26 lines · Dan Carpenter
Quoted 25 lines · Devendra Naga

as we do a strcpy(smdrv_ptr->fb_struct->fix->id, name), and the name here in sm7xxx_probe is not having any assignment, and which leads to copying of the garbage value into the id field of the fix struct of fb interface struct. fix it by copying the name before calling alloc_fbinfo

---
Only compile tested
This patch is not tested using the hardware... if any one is having this hardware, i request them to
please test this

 drivers/staging/sm7xxfb/sm7xxfb.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/sm7xxfb/sm7xxfb.c +2 -0
index 1c1780c..d3957ef 100644
@@ -798,16 +798,17 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
      if (err)
              return err;
 
+     sprintf(name, "sm%Xfb", ent->device);
+
      sfb = smtc_alloc_fb_info(pdev, name);
 
Quoted 6 lines

drivers/staging/sm7xxfb/sm7xxfb.c static int __devinit smtcfb_pci_probe(struct pci_dev *pdev, · line 807

Quoted 3 lines
drivers/staging/sm7xxfb/sm7xxfb.c +2 -0
+     sfb->chip_id = ent->device;
+
      if (!sfb) {

Thanks for fixing this, and well done for spotting the bug.

Thanks Dan...

Quoted 4 lines

There is a dereference before the check here, but I see you resent this in another thread. Next time could you respond to the original with a message which says to not apply it.

Quoted 5 lines

Sure but i have a doubt.

since we do V++ after every change to the sent patch , do we really need to say that please dont apply this patch and there's one more patch coming with fix?

Yes. The second email very far away from the first one if you are subscribed to a bunch of high traffic email lists.

I reviewed your patch. I saw the bug. I saw that no one else had replied to your email. I almost didn't notice the v2 email. It's annoying. It's not hard to just send an email. "Oops. There is a bug here. I'll sent a v2."

regards,
dan carpenter