[Mesa-dev] [PATCH] gallium/winsys/kms: don't unmap what wasn't mapped

Emil Velikov emil.l.velikov at gmail.com
Fri Aug 17 13:27:16 UTC 2018

On 16 August 2018 at 21:37, Ray Strode <halfline at gmail.com> wrote:
> From: Ray Strode <rstrode at redhat.com>
> 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.
Nicely done - I forgot that MAP_FAILED (-1 really) is the recommended
way to handle mmap/munmap.
Since this patch is a superior version of the one Jan sent earlier,
I'll push this shortly.

For posterity:

Fixes: d891f28df9a ("gallium/winsys/kms: Fix possible leak in map/unmap.")
Cc: Lepton Wu <lepton at chromium.org>
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>


More information about the mesa-dev mailing list