Skip to contentSkip to conversation

drm/nouveau/bios: fix incorrect kfree in platform_init

PATCH In review wuxu.wu 3 participants 4 messages Jan 3, 2020 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

wuxu.wu

author
#0 lore raw

PATCH 1/1 drm/nouveau/bios: fix incorrect kfree in platform_init

Hi, I think there has a incorrect kfree in pcirom_init function. In pcirom_init function priv porinter could be free only when priv != null and priv->rom is null.

---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c +2 -1
index 9b91da0..d776e01 100644
@@ -70,8 +70,9 @@ pcirom_init(struct nvkm_bios *bios, const char *name)
 			    (priv->rom = pci_map_rom(pdev, &priv->size))) {
 				priv->pdev = pdev;
 				return priv;
+			} else {
+			    kfree(priv);
 			}
-			kfree(priv);
 		}
 		pci_disable_rom(pdev);
 	}
Signature · 1 line
2.7.4

A message that is not in the archive (sent off-list or not yet received): 1578039033-6458-1-git-send-email-wuxu.wu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org

#2 lore raw

NACK. The before and after of this patch are functionally identical. The if-block returns unconditionally ("return priv;"), so the kfree will only ever be reached if the condition in the if-statement evaluates to false. Explicitly writing out an else-block is thus superfluous.

Op 03-01-2020 om 09:10 schreef wuxu.wu:

Quoted 14 lines

Hi, I think there has a incorrect kfree in pcirom_init function. In pcirom_init function priv porinter could be free only when priv != null and priv->rom is null.

---
  drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c +0 -0
index 9b91da0..d776e01 100644

drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c pcirom_init(struct nvkm_bios *bios, const char *name) · line 78

Quoted 10 lines
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c +2 -1
@@ -70,8 +70,9 @@ pcirom_init(struct nvkm_bios *bios, const char *name)
  			    (priv->rom = pci_map_rom(pdev, &priv->size))) {
  				priv->pdev = pdev;
  				return priv;
+			} else {
+			    kfree(priv);
  			}
-			kfree(priv);
  		}
  		pci_disable_rom(pdev);
  	}

_______________________________________________
Nouveau mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#3 lore raw
In reply to a message not in the archive

(re-sending as plain text)

NACK. The before and after of this patch are functionally identical. The if-block returns unconditionally ("return priv;"), so the kfree will only ever be reached if the condition in the if-statement evaluates to false. Explicitly writing out an else-block is thus superfluous.

Op 03-01-2020 om 09:10 schreef wuxu.wu:

Quoted 25 lines

Hi, I think there has a incorrect kfree in pcirom_init function. In pcirom_init function priv porinter could be free only when priv != null and priv->rom is null.

---
  drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c +2 -1
index 9b91da0..d776e01 100644
@@ -70,8 +70,9 @@ pcirom_init(struct nvkm_bios *bios, const char *name)
  			    (priv->rom = pci_map_rom(pdev, &priv->size))) {
  				priv->pdev = pdev;
  				return priv;
+			} else {
+			    kfree(priv);
  			}
-			kfree(priv);
  		}
  		pci_disable_rom(pdev);
  	}

A message that is not in the archive (sent off-list or not yet received): fd3273d3-5814-be43-dbec-e49bc7990705-NQbd8FSOZ1kdnm+yROfE0A@public.gmane.org

#5 lore raw

Thank you, I got it

Quoted 24 lines · Roy Spliet

(re-sending as plain text)

NACK. The before and after of this patch are functionally identical. The if-block returns unconditionally ("return priv;"), so the kfree will only ever be reached if the condition in the if-statement evaluates to false. Explicitly writing out an else-block is thus superfluous.

Op 03-01-2020 om 09:10 schreef wuxu.wu:

Quoted 19 lines

Hi, I think there has a incorrect kfree in pcirom_init function. In pcirom_init function priv porinter could be free only when priv != null and priv->rom is null.

---
  drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c +2 -0
index 9b91da0..d776e01 100644
@@ -70,8 +70,9 @@ pcirom_init(struct nvkm_bios *bios, const char *name)
                   (priv->rom = pci_map_rom(pdev, &priv->size))) {
                   priv->pdev = pdev;
                   return priv;
+            } else {
+                kfree(priv);
Quoted 8 lines

drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c pcirom_init(struct nvkm_bios *bios, const char *name) · line 78

Quoted 6 lines
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c +0 -1
               }
-            kfree(priv);
           }
           pci_disable_rom(pdev);
       }

.

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau