[Mesa-dev] [PATCH] gallium/winsys/kms: do not munmap NULL pointers
Jan Palus
atler at pld-linux.org
Fri Jul 13 19:57:55 UTC 2018
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107098
Signed-off-by: Jan Palus <atler at pld-linux.org>
---
src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
index 3fe1b1a731..7aa86df0af 100644
--- a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
@@ -368,10 +368,14 @@ kms_sw_displaytarget_unmap(struct sw_winsys *ws,
DEBUG_PRINT("KMS-DEBUG: unmapped buffer %u (was %p)\n", kms_sw_dt->handle, kms_sw_dt->mapped);
DEBUG_PRINT("KMS-DEBUG: unmapped buffer %u (was %p)\n", kms_sw_dt->handle, kms_sw_dt->ro_mapped);
- munmap(kms_sw_dt->mapped, kms_sw_dt->size);
- kms_sw_dt->mapped = NULL;
- munmap(kms_sw_dt->ro_mapped, kms_sw_dt->size);
- kms_sw_dt->ro_mapped = NULL;
+ if (kms_sw_dt->mapped != NULL) {
+ munmap(kms_sw_dt->mapped, kms_sw_dt->size);
+ kms_sw_dt->mapped = NULL;
+ }
+ if (kms_sw_dt->ro_mapped != NULL) {
+ munmap(kms_sw_dt->ro_mapped, kms_sw_dt->size);
+ kms_sw_dt->ro_mapped = NULL;
+ }
}
static struct sw_displaytarget *
--
2.18.0
More information about the mesa-dev
mailing list