Skip to contentSkip to conversation

drm: nouveau: fix nvbe leakage

PATCH In review Geyslan G. Bem 3 participants 6 messages Oct 7, 2013 – Oct 8, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: nouveau: fix nvbe leakage

Free memory allocated to nvbe when returning NULL.

---
 drivers/gpu/drm/nouveau/nouveau_sgdma.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/nouveau/nouveau_sgdma.c +3 -0
index 0843ebc..af8b66d 100644
@@ -105,6 +105,9 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
 		nvbe->ttm.ttm.func = &nv50_sgdma_backend;
 
 	if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page))
+	{
+		kfree(nvbe);
 		return NULL;
+	}
 	return &nvbe->ttm.ttm;
 }
Signature · 1 line
1.8.4
#1 lore raw

----- Original Message -----

Quoted 9 lines

From: "Geyslan G. Bem" <[email protected]>
To: [email protected], [email protected], [email protected]
Cc: [email protected], [email protected], "Geyslan G. Bem" <[email protected]>
Sent: Tuesday, 8 October, 2013 8:14:26 AM
Subject: [PATCH] drm: nouveau: fix nvbe leakage

Free memory allocated to nvbe when returning NULL.

NACK. ttm_dma_tt_init() calls the destructor if it fails, which frees the memory.

Ben.

Quoted 23 lines
---
 drivers/gpu/drm/nouveau/nouveau_sgdma.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/nouveau/nouveau_sgdma.c +3 -1
index 0843ebc..af8b66d 100644
@@ -105,6 +105,9 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
 		nvbe->ttm.ttm.func = &nv50_sgdma_backend;
 
 	if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page))
+	{
+		kfree(nvbe);
 		return NULL;
+	}
 	return &nvbe->ttm.ttm;
 }
--

1.8.4

#2 lore raw

Hi,

Quoted 7 lines · Ben Skeggs

----- Original Message -----

Quoted 6 lines

From: "Geyslan G. Bem" <[email protected]>
To: [email protected], [email protected], [email protected]
Cc: [email protected], [email protected], "Geyslan G. Bem" <[email protected]>
Sent: Tuesday, 8 October, 2013 8:14:26 AM
Subject: [PATCH] drm: nouveau: fix nvbe leakage

Quoted 7 lines
Quoted 3 lines

Free memory allocated to nvbe when returning NULL.

NACK. ttm_dma_tt_init() calls the destructor if it fails, which frees the memory.

Ben.

But ttm_tt_destroy() just handles the ttm_tt part from nvbe, the nvbe pointer itself is not being free'd.

Quoted 28 lines
Quoted 20 lines
---
 drivers/gpu/drm/nouveau/nouveau_sgdma.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/nouveau/nouveau_sgdma.c +3 -1
index 0843ebc..af8b66d 100644
@@ -105,6 +105,9 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
              nvbe->ttm.ttm.func = &nv50_sgdma_backend;
 
      if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page))
+     {
+             kfree(nvbe);
              return NULL;
+     }
      return &nvbe->ttm.ttm;
 }
--
Quoted 3 lines

1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
Regards,
Felipe Pena
#3 lore raw

Felipe, thank you too.

I realized this after a code review.

Ben, what do you think?

Geyslan Gregório Bem
hackingbits.com

2013/10/7 Felipe Pena <[email protected]>:

Quoted 55 lines

Hi,

Quoted 7 lines · Ben Skeggs

----- Original Message -----

Quoted 6 lines

From: "Geyslan G. Bem" <[email protected]>
To: [email protected], [email protected], [email protected]
Cc: [email protected], [email protected], "Geyslan G. Bem" <[email protected]>
Sent: Tuesday, 8 October, 2013 8:14:26 AM
Subject: [PATCH] drm: nouveau: fix nvbe leakage

Quoted 7 lines
Quoted 3 lines

Free memory allocated to nvbe when returning NULL.

NACK. ttm_dma_tt_init() calls the destructor if it fails, which frees the memory.

Ben.

But ttm_tt_destroy() just handles the ttm_tt part from nvbe, the nvbe pointer itself is not being free'd.

Quoted 12 lines
Quoted 12 lines
---
 drivers/gpu/drm/nouveau/nouveau_sgdma.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/nouveau/nouveau_sgdma.c +0 -0
index 0843ebc..af8b66d 100644
@@ -105,6 +105,9 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
              nvbe->ttm.ttm.func = &nv50_sgdma_backend;
 
Quoted 16 lines
Quoted 11 lines
drivers/gpu/drm/nouveau/nouveau_sgdma.c +3 -1
      if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page))
+     {
+             kfree(nvbe);
              return NULL;
+     }
      return &nvbe->ttm.ttm;
 }
--

1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

--
Regards,
Felipe Pena

#4 lore raw

----- Original Message -----

Quoted 11 lines

From: "Geyslan Gregório Bem" <[email protected]>
To: "Felipe Pena" <[email protected]>
Cc: "Ben Skeggs" <[email protected]>, [email protected], [email protected], [email protected], "kernel-br" <[email protected]>
Sent: Tuesday, 8 October, 2013 9:39:02 AM
Subject: Re: [PATCH] drm: nouveau: fix nvbe leakage

Felipe, thank you too.

I realized this after a code review.

Quoted 29 lines

Ben, what do you think?

Geyslan Gregório Bem
hackingbits.com

2013/10/7 Felipe Pena <[email protected]>:

Quoted 22 lines

Hi,

Quoted 8 lines · Ben Skeggs

----- Original Message -----

Quoted 7 lines

From: "Geyslan G. Bem" <[email protected]>
To: [email protected], [email protected], [email protected]
Cc: [email protected], [email protected], "Geyslan G. Bem" <[email protected]>
Sent: Tuesday, 8 October, 2013 8:14:26 AM
Subject: [PATCH] drm: nouveau: fix nvbe leakage

Quoted 8 lines
Quoted 3 lines

Free memory allocated to nvbe when returning NULL.

NACK. ttm_dma_tt_init() calls the destructor if it fails, which frees the memory.

Ben.

But ttm_tt_destroy() just handles the ttm_tt part from nvbe, the nvbe pointer itself is not being free'd.

Actually look at ttm_tt_destroy() and you'll see that right at the end it goes ttm->func->destroy(ttm), which is nouveau_sgdma_destroy().

Ben.

Quoted 37 lines
Quoted 36 lines
Quoted 22 lines
Quoted 22 lines
---
 drivers/gpu/drm/nouveau/nouveau_sgdma.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/nouveau/nouveau_sgdma.c +3 -0
index 0843ebc..af8b66d 100644
@@ -105,6 +105,9 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
              nvbe->ttm.ttm.func = &nv50_sgdma_backend;
 
      if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags,
      dummy_read_page))
+     {
+             kfree(nvbe);
              return NULL;
+     }
      return &nvbe->ttm.ttm;

}
--

Quoted 8 lines
Quoted 3 lines

1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

--
Regards,
Felipe Pena

#5 lore raw

Rather, the first member of nvbe is ttm (same address). Got it.

Please, disregard this patch. Thank you.

Geyslan Gregório Bem
hackingbits.com

2013/10/7 Ben Skeggs <[email protected]>:

Quoted 81 lines

----- Original Message -----

Quoted 11 lines

From: "Geyslan Gregório Bem" <[email protected]>
To: "Felipe Pena" <[email protected]>
Cc: "Ben Skeggs" <[email protected]>, [email protected], [email protected], [email protected], "kernel-br" <[email protected]>
Sent: Tuesday, 8 October, 2013 9:39:02 AM
Subject: Re: [PATCH] drm: nouveau: fix nvbe leakage

Felipe, thank you too.

I realized this after a code review.

Quoted 29 lines

Ben, what do you think?

Geyslan Gregório Bem
hackingbits.com

2013/10/7 Felipe Pena <[email protected]>:

Quoted 22 lines

Hi,

Quoted 8 lines · Ben Skeggs

----- Original Message -----

Quoted 7 lines

From: "Geyslan G. Bem" <[email protected]>
To: [email protected], [email protected], [email protected]
Cc: [email protected], [email protected], "Geyslan G. Bem" <[email protected]>
Sent: Tuesday, 8 October, 2013 8:14:26 AM
Subject: [PATCH] drm: nouveau: fix nvbe leakage

Quoted 8 lines
Quoted 3 lines

Free memory allocated to nvbe when returning NULL.

NACK. ttm_dma_tt_init() calls the destructor if it fails, which frees the memory.

Ben.

But ttm_tt_destroy() just handles the ttm_tt part from nvbe, the nvbe pointer itself is not being free'd.

Actually look at ttm_tt_destroy() and you'll see that right at the end it goes ttm->func->destroy(ttm), which is nouveau_sgdma_destroy().

Ben.

Quoted 37 lines
Quoted 36 lines
Quoted 22 lines
Quoted 22 lines
---
 drivers/gpu/drm/nouveau/nouveau_sgdma.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/nouveau/nouveau_sgdma.c +3 -0
index 0843ebc..af8b66d 100644
@@ -105,6 +105,9 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
              nvbe->ttm.ttm.func = &nv50_sgdma_backend;
 
      if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags,
      dummy_read_page))
+     {
+             kfree(nvbe);
              return NULL;
+     }
      return &nvbe->ttm.ttm;

}
--

Quoted 8 lines
Quoted 3 lines

1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

--
Regards,
Felipe Pena