Skip to contentSkip to conversation

intel: avoid null pointer dereference

PATCH In review Thomas Hindoe Paaboel Andersen 2 participants 4 messages Feb 2, 2017 – Feb 7, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 intel: avoid null pointer dereference

Introduced in 028715ee

Move the dereference after the null check.

---
 intel/intel_decode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
intel/intel_decode.c +2 -1
index 803d202..2721ffd 100644
@@ -3899,7 +3899,7 @@ drm_intel_decode(struct drm_intel_decode *ctx)
 	int ret;
 	unsigned int index = 0;
 	uint32_t devid;
-	int size = ctx->base_count * 4;
+	int size;
 	void *temp;
 
 	if (!ctx)
@@ -3909,6 +3909,7 @@ drm_intel_decode(struct drm_intel_decode *ctx)
 	 * the batchbuffer.  This lets us avoid a bunch of length
 	 * checking in statically sized packets.
 	 */
+	size = ctx->base_count * 4;
 	temp = malloc(size + 4096);
 	memcpy(temp, ctx->base_data, size);
 	memset((char *)temp + size, 0xd0, 4096);
Signature · 6 lines
2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Thomas Hindoe Paaboel Andersen

Introduced in 028715ee

Move the dereference after the null check.

Fixes 028715ee707469189505 ("intel: Avoid the need for most overflow

checks by using a scratch page.")

Quoted 28 lines
---
 intel/intel_decode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
intel/intel_decode.c +2 -1
index 803d202..2721ffd 100644
@@ -3899,7 +3899,7 @@ drm_intel_decode(struct drm_intel_decode *ctx)
 	int ret;
 	unsigned int index = 0;
 	uint32_t devid;
-	int size = ctx->base_count * 4;
+	int size;
 	void *temp;
 
 	if (!ctx)
@@ -3909,6 +3909,7 @@ drm_intel_decode(struct drm_intel_decode *ctx)
 	 * the batchbuffer.  This lets us avoid a bunch of length
 	 * checking in statically sized packets.
 	 */
+	size = ctx->base_count * 4;
 	temp = malloc(size + 4096);
 	memcpy(temp, ctx->base_data, size);
 	memset((char *)temp + size, 0xd0, 4096);
Signature · 1 line
2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 9 lines · Eric Engestrom
Quoted 3 lines · Thomas Hindoe Paaboel Andersen

Introduced in 028715ee

Move the dereference after the null check.

Fixes 028715ee707469189505 ("intel: Avoid the need for most overflow

checks by using a scratch page.")

Thanks. I do not have commit access. Can I ask you to push it?

Quoted 17 lines
Quoted 17 lines
---
 intel/intel_decode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
intel/intel_decode.c +1 -1
index 803d202..2721ffd 100644
@@ -3899,7 +3899,7 @@ drm_intel_decode(struct drm_intel_decode *ctx)
      int ret;
      unsigned int index = 0;
      uint32_t devid;
-     int size = ctx->base_count * 4;
+     int size;
      void *temp;
 
Quoted 12 lines
Quoted 10 lines
intel/intel_decode.c +1 -1
      if (!ctx)
@@ -3909,6 +3909,7 @@ drm_intel_decode(struct drm_intel_decode *ctx)
       * the batchbuffer.  This lets us avoid a bunch of length
       * checking in statically sized packets.
       */
+     size = ctx->base_count * 4;
      temp = malloc(size + 4096);
      memcpy(temp, ctx->base_data, size);
      memset((char *)temp + size, 0xd0, 4096);
--
Quoted 2 lines

2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 6 lines · Thomas H.P. Andersen
Quoted 4 lines · Eric Engestrom
Quoted 2 lines · Thomas Hindoe Paaboel Andersen

Introduced in 028715ee

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Move the dereference after the null check.

Fixes 028715ee707469189505 ("intel: Avoid the need for most overflow

checks by using a scratch page.")

Thanks. I do not have commit access. Can I ask you to push it?

I actually don't have commit access to libdrm either :)

Emil, can you push this (and the autogen patches)?

Cheers,
Eric

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines

---
 intel/intel_decode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
intel/intel_decode.c +1 -1
index 803d202..2721ffd 100644
@@ -3899,7 +3899,7 @@ drm_intel_decode(struct drm_intel_decode *ctx)
      int ret;
      unsigned int index = 0;
      uint32_t devid;
-     int size = ctx->base_count * 4;
+     int size;
      void *temp;
 
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
intel/intel_decode.c +0 -0
      if (!ctx)
@@ -3909,6 +3909,7 @@ drm_intel_decode(struct drm_intel_decode *ctx)
       * the batchbuffer.  This lets us avoid a bunch of length
       * checking in statically sized packets.
Quoted 8 lines
Quoted 8 lines
intel/intel_decode.c +1 -1
       */
+     size = ctx->base_count * 4;
      temp = malloc(size + 4096);
      memcpy(temp, ctx->base_data, size);
      memset((char *)temp + size, 0xd0, 4096);
--

2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel