OSDN Git Service

gallium/winsys/kms: don't unmap what wasn't mapped
authorRay Strode <rstrode@redhat.com>
Thu, 16 Aug 2018 20:37:25 +0000 (16:37 -0400)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 17 Aug 2018 16:16:32 +0000 (17:16 +0100)
commit9baff597ce021f7691187b0d1d1bbc16d07b13e1
treecd195feafd8900b273cd2822fe9413b7eb20edf6
parent0aa80abf257edde027378b6826e60fa8088ac3df
gallium/winsys/kms: don't unmap what wasn't mapped

At the moment, depending on pipe transfer flags, the dumb
buffer map address can end up at either kms_sw_dt->ro_mapped
or kms_sw_dt->mapped.

When it's time to unmap the dumb buffer, both locations get unmapped,
even though one is probably initialized to 0.

That leads to the code segment getting unmapped at runtime and
crashes when trying to call into unrelated code.

This commit addresses the problem by using MAP_FAILED instead of
NULL for ro_mapped and mapped when the dumb buffer is unmapped,
and only unmapping mapped addresses at unmap time.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107098
Signed-off-by: Ray Strode <rstrode@redhat.com>
Fixes: d891f28df9a ("gallium/winsys/kms: Fix possible leak in map/unmap.")
Cc: Lepton Wu <lepton@chromium.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c