Skip to contentSkip to conversation

drm/v3d: Fix double free in v3d_submit_cl_ioctl()

PATCH In review Dan Carpenter 3 participants 5 messages Oct 24, 2019 – Oct 26, 2020

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

PATCH 1/1 drm/v3d: Fix double free in v3d_submit_cl_ioctl()

Originally this error path used to leak "bin" but then we accidentally applied two separate commits to fix it and ended up with a double free.

---
Hi Stephen,

I think this one is actually just a linux-next issue and the Fixes tag would point to commit f8593384f83f ("Merge remote-tracking branch 'drm/drm-next'").

The original commits are 0d352a3a8a1f ("drm/v3d: don't leak bin job if v3d_job_init fails.") and commit 29cd13cfd762 ("drm/v3d: Fix memory leak in v3d_submit_cl_ioctl").

I'm not totally sure how you guys address this normally but presumably you are experts at dealing with merge issues. :)

 drivers/gpu/drm/v3d/v3d_gem.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/v3d/v3d_gem.c +0 -1
index 549dde83408b..37515e47b47e 100644
@@ -568,7 +568,6 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
 		ret = v3d_job_init(v3d, file_priv, &bin->base,
 				   v3d_job_free, args->in_sync_bcl);
 		if (ret) {
-			kfree(bin);
 			v3d_job_put(&render->base);
 			kfree(bin);
 			return ret;
Signature · 1 line
2.20.1
#1 lore raw

Hi Dan,

Quoted 27 lines · On Thu, 24 Oct 2019 23:53:06 +0300 Dan Carpenter <[email protected]>…

Originally this error path used to leak "bin" but then we accidentally applied two separate commits to fix it and ended up with a double free.

---
Hi Stephen,

I think this one is actually just a linux-next issue and the Fixes tag would point to commit f8593384f83f ("Merge remote-tracking branch 'drm/drm-next'").

The original commits are 0d352a3a8a1f ("drm/v3d: don't leak bin job if v3d_job_init fails.") and commit 29cd13cfd762 ("drm/v3d: Fix memory leak in v3d_submit_cl_ioctl").

I'm not totally sure how you guys address this normally but presumably you are experts at dealing with merge issues. :)

 drivers/gpu/drm/v3d/v3d_gem.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/v3d/v3d_gem.c +0 -0
index 549dde83408b..37515e47b47e 100644

drivers/gpu/drm/v3d/v3d_gem.c v3d_submit_cl_ioctl(struct drm_device *dev, void *data, · line 573

Quoted 7 lines
drivers/gpu/drm/v3d/v3d_gem.c +0 -1
@@ -568,7 +568,6 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
 		ret = v3d_job_init(v3d, file_priv, &bin->base,
 				   v3d_job_free, args->in_sync_bcl);
 		if (ret) {
-			kfree(bin);
 			v3d_job_put(&render->base);
 			kfree(bin);
 			return ret;

I will just apply this as part of the drm tree merge until Dave merges the drm-misc-fixes tree and fixes this up.

Signature · 2 lines
Cheers,
Stephen Rothwell
#2 lore raw
Quoted 25 lines · Stephen Rothwell

Hi Dan,

Quoted 22 lines · On Thu, 24 Oct 2019 23:53:06 +0300 Dan Carpenter <[email protected]>…

Originally this error path used to leak "bin" but then we accidentally applied two separate commits to fix it and ended up with a double free.

---
Hi Stephen,

I think this one is actually just a linux-next issue and the Fixes tag would point to commit f8593384f83f ("Merge remote-tracking branch 'drm/drm-next'").

The original commits are 0d352a3a8a1f ("drm/v3d: don't leak bin job if v3d_job_init fails.") and commit 29cd13cfd762 ("drm/v3d: Fix memory leak in v3d_submit_cl_ioctl").

I'm not totally sure how you guys address this normally but presumably you are experts at dealing with merge issues. :)

 drivers/gpu/drm/v3d/v3d_gem.c | 1 -
 1 file changed, 1 deletion(-)
Quoted 16 lines

drivers/gpu/drm/v3d/v3d_gem.c v3d_submit_cl_ioctl(struct drm_device *dev, void *data, · line 573

Quoted 12 lines
drivers/gpu/drm/v3d/v3d_gem.c +0 -1
index 549dde83408b..37515e47b47e 100644
@@ -568,7 +568,6 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
 		ret = v3d_job_init(v3d, file_priv, &bin->base,
 				   v3d_job_free, args->in_sync_bcl);
 		if (ret) {
-			kfree(bin);
 			v3d_job_put(&render->base);
 			kfree(bin);
 			return ret;

I will just apply this as part of the drm tree merge until Dave merges the drm-misc-fixes tree and fixes this up.

It turns out that Dave never fixed it. Let me resend.

regards,
dan carpenter

#3 lore raw

PATCH RESEND 1/1 drm/v3d: Fix double free in v3d_submit_cl_ioctl()

In reply to Dan Carpenter

Originally this error path used to leak "bin" but then we accidentally applied two separate commits to fix it and ended up with a double free.

---
Resending a year later because it was confusing at the time who should apply this and it fell through the cracks. For some reason the kbuild bot flagged it as a new warning so it showed up on my radar again.

 drivers/gpu/drm/v3d/v3d_gem.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/v3d/v3d_gem.c +0 -1
index 549dde83408b..37515e47b47e 100644
@@ -568,7 +568,6 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
 		ret = v3d_job_init(v3d, file_priv, &bin->base,
 				   v3d_job_free, args->in_sync_bcl);
 		if (ret) {
-			kfree(bin);
 			v3d_job_put(&render->base);
 			kfree(bin);
 			return ret;
Signature · 1 line
2.20.1
#4 lore raw
Quoted 8 lines · Dan Carpenter

Originally this error path used to leak "bin" but then we accidentally applied two separate commits to fix it and ended up with a double free.

---
Resending a year later because it was confusing at the time who should apply this and it fell through the cracks. For some reason the kbuild bot flagged it as a new warning so it showed up on my radar again.

Applied, thanks!
Maxime