fbdev: allow apertures == NULL in remove_conflicting_framebuffers()
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Sat, 1 Sep 2018 14:08:44 +0000 (16:08 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 3 Sep 2018 16:14:55 +0000 (18:14 +0200)
Interpret (otherwise-invalid) NULL apertures argument to mean all-memory
range. This will allow to remove several duplicates of this code
from drivers in following patches.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/b5fed539fe569035139c8594c23effd8c39f12ca.1535810304.git.mirq-linux@rere.qmqm.pl
drivers/video/fbdev/core/fbmem.c

index bd870bdc14091e1da4d5f9cb7ed7fbab164658d0..21f3d31d3c2e75a05398a23d306eb9c31f25f52f 100644 (file)
@@ -1797,11 +1797,25 @@ int remove_conflicting_framebuffers(struct apertures_struct *a,
                                    const char *name, bool primary)
 {
        int ret;
+       bool do_free = false;
+
+       if (!a) {
+               a = alloc_apertures(1);
+               if (!a)
+                       return -ENOMEM;
+
+               a->ranges[0].base = 0;
+               a->ranges[0].size = ~0;
+               do_free = true;
+       }
 
        mutex_lock(&registration_lock);
        ret = do_remove_conflicting_framebuffers(a, name, primary);
        mutex_unlock(&registration_lock);
 
+       if (do_free)
+               kfree(a);
+
        return ret;
 }
 EXPORT_SYMBOL(remove_conflicting_framebuffers);