wuxu.wu
2020-Jan-03 08:10 UTC
[Nouveau] [PATCH] 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. Signed-off-by: wuxu.wu <wuxu.wu at huawei.com> --- drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c index 9b91da0..d776e01 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c @@ -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); } -- 2.7.4
Roy Spliet
2020-Jan-03 11:53 UTC
[Nouveau] [PATCH] drm/nouveau/bios: fix incorrect kfree in platform_init
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:> 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. > > Signed-off-by: wuxu.wu <wuxu.wu at huawei.com> > --- > drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c > index 9b91da0..d776e01 100644 > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c > @@ -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); > }-------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.freedesktop.org/archives/nouveau/attachments/20200103/45c4fdb7/attachment.htm>
Roy Spliet
2020-Jan-03 11:58 UTC
[Nouveau] [PATCH] drm/nouveau/bios: fix incorrect kfree in platform_init
(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:> 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. > > Signed-off-by: wuxu.wu <wuxu.wu at huawei.com> > --- > drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c > index 9b91da0..d776e01 100644 > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c > @@ -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); > } >
Wuxu (Max)
2020-Jan-03 13:25 UTC
[Nouveau] [PATCH] drm/nouveau/bios: fix incorrect kfree in platform_init
Thank you, I got it On 2020/1/3 19:58, Roy Spliet wrote:> (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: >> 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. >> >> Signed-off-by: wuxu.wu <wuxu.wu at huawei.com> >> --- >> ? drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c | 3 ++- >> ? 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c >> index 9b91da0..d776e01 100644 >> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c >> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c >> @@ -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); >> ????? } >> > > .
Possibly Parallel Threads
- [PATCH] drm/nouveau/bios: fix incorrect kfree in platform_init
- [PATCH] drm/nouveau/bios: fix incorrect kfree in platform_init
- [PATCH] drm/nouveau/bios: fix incorrect kfree in platform_init
- [PATCH v3] PCI: Use ioremap(), not phys_to_virt() for platform ROM
- [PATCH v3] PCI: Use ioremap(), not phys_to_virt() for platform ROM