From patchwork Tue Feb 13 18:07:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Malaterre X-Patchwork-Id: 10218171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AB4CC6055C for ; Wed, 14 Feb 2018 08:42:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 960A728988 for ; Wed, 14 Feb 2018 08:42:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8754828C99; Wed, 14 Feb 2018 08:42:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D1D528988 for ; Wed, 14 Feb 2018 08:42:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1E1C6E39B; Wed, 14 Feb 2018 08:42:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id B1C46892D8 for ; Tue, 13 Feb 2018 18:08:22 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id r71so17778421wmd.1 for ; Tue, 13 Feb 2018 10:08:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=EkmZo0aNMdfJ6M3CnBUgasm6wzpeluUkqJTKjA8u2rw=; b=EbU7CQJFM4o3sujQP1Z1ql7Qe81y+bdJ2F4WHHr2va4NO9b1QTN+O+zfWTqeP1s480 ITAxxjjT1VzSUii6HTFnNTc4zbj5A801NrgTUTdN51yfbUmHp0AdSncG64v6du2fmPRG t8tI5wQy7nKfShhlX/FHl1SZf0wEC7X1kyx6r2tE3tvnxXeHD+vJCo53YvdV2KbKRkpr vp+lVJuvYBEjrfXxds0QWnbC5uwKp5RoK+kfzY27wCxzIWW0g0nOCg7qPaGP/SyiqevM XIY00UIboOpRVuw/eq/enibVNRVjCzJM4N4BamM+mZdea3G6CK75Hczx8KrThGR9K2/s TQtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=EkmZo0aNMdfJ6M3CnBUgasm6wzpeluUkqJTKjA8u2rw=; b=NEURcFOiTSVq7Kv07teSClUAazyqY4nEsXnvfhwLDn2RUkI0bLHG8YIrIiLP813TaY a92pI9dK97b1fxhV+0xNXb8wed0NH9lHZHlbGXZEu9/Z14Hgf2tWPQbJ9aFydzH/F6rG Ybal3NoR9ffMJU4TYkgNVzEiZFaTSFNVYiL2Xgrlxxq0nvcVW+SoHBLfA7iajFZkCCsx E5EBZRtM9Hz94gwKQddc7j/Pgm1WF/Y8T+fccgBWi3h7GMPHXM3H2D4an+2GFLhHpPIp LjpReO0LmAylhW3Wk3jXBrCN6zRC3G86oSxa+Eno4vcbTaUpfwcuAeAjoB74NH4uQrXA BLcg== X-Gm-Message-State: APf1xPD2DKoMlMLVRhQ9JVjjRBmScxct3H1R8BJ/RRiC/cZVQ/3OZ1mb FMlruSG/nRRzs/5TXBUmKoU= X-Google-Smtp-Source: AH8x227L8ocSem8Yiwo6j+fpeZWBlP8M0u9UZJHJChAoX18cBSxYvcKqRQb+JCHVAmD+ORRIM9tDFg== X-Received: by 10.28.17.17 with SMTP id 17mr2173440wmr.123.1518545301062; Tue, 13 Feb 2018 10:08:21 -0800 (PST) Received: from macbookpro.malat.net (bru31-1-78-225-226-121.fbx.proxad.net. [78.225.226.121]) by smtp.gmail.com with ESMTPSA id t196sm1758307wme.47.2018.02.13.10.08.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2018 10:08:20 -0800 (PST) Received: by macbookpro.malat.net (Postfix, from userid 1000) id 5C62C10C04A4; Tue, 13 Feb 2018 19:08:19 +0100 (CET) From: Mathieu Malaterre To: Bartlomiej Zolnierkiewicz Subject: [PATCH] video: offb: Deallocate the color map Date: Tue, 13 Feb 2018 19:07:45 +0100 Message-Id: <20180213180747.12666-1-malat@debian.org> X-Mailer: git-send-email 2.11.0 X-Mailman-Approved-At: Wed, 14 Feb 2018 08:42:49 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mathieu Malaterre , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The function offb_destroy did not deallocate the color map leaving some memory around after destruction. Call the color map deallocate function to remove the memory leak. Handle another case where color map should have been deallocated during an error code path. Fix memory leaks reported by kmemleak: # dmesg ... [ 1884.719941] kmemleak: 3 new suspected memory leaks (see /sys/kernel/debug/kmemleak) # cat /sys/kernel/debug/kmemleak unreferenced object 0xde3d9000 (size 512): comm "swapper", pid 1, jiffies 4294892827 (age 1906.784s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 aa aa aa aa aa aa aa aa ................ 55 55 55 55 55 55 55 55 ff ff ff ff ff ff ff ff UUUUUUUU........ backtrace: [] fb_alloc_cmap_gfp+0x54/0x15c [] offb_init_nodriver+0x8e8/0xa3c [] offb_init+0xd0/0x164 [<322f82a3>] do_one_initcall+0x4c/0x178 [] kernel_init_freeable+0x138/0x1cc [<2a17fa0e>] kernel_init+0x24/0x118 [<4079749a>] ret_from_kernel_thread+0x5c/0x64 unreferenced object 0xde3d9200 (size 512): comm "swapper", pid 1, jiffies 4294892827 (age 1906.784s) hex dump (first 32 bytes): 00 00 00 00 aa aa aa aa 00 00 00 00 55 55 aa aa ............UU.. 55 55 55 55 ff ff ff ff 55 55 55 55 ff ff ff ff UUUU....UUUU.... backtrace: [<4bf3594d>] fb_alloc_cmap_gfp+0x6c/0x15c [] offb_init_nodriver+0x8e8/0xa3c [] offb_init+0xd0/0x164 [<322f82a3>] do_one_initcall+0x4c/0x178 [] kernel_init_freeable+0x138/0x1cc [<2a17fa0e>] kernel_init+0x24/0x118 [<4079749a>] ret_from_kernel_thread+0x5c/0x64 unreferenced object 0xde3d9600 (size 512): comm "swapper", pid 1, jiffies 4294892827 (age 1906.784s) hex dump (first 32 bytes): 00 00 aa aa 00 00 aa aa 00 00 aa aa 00 00 aa aa ................ 55 55 ff ff 55 55 ff ff 55 55 ff ff 55 55 ff ff UU..UU..UU..UU.. backtrace: [<23a3ea03>] fb_alloc_cmap_gfp+0x84/0x15c [] offb_init_nodriver+0x8e8/0xa3c [] offb_init+0xd0/0x164 [<322f82a3>] do_one_initcall+0x4c/0x178 [] kernel_init_freeable+0x138/0x1cc [<2a17fa0e>] kernel_init+0x24/0x118 [<4079749a>] ret_from_kernel_thread+0x5c/0x64 Signed-off-by: Mathieu Malaterre --- drivers/video/fbdev/offb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/offb.c b/drivers/video/fbdev/offb.c index 6f65d132eba1..30786445de04 100644 --- a/drivers/video/fbdev/offb.c +++ b/drivers/video/fbdev/offb.c @@ -282,6 +282,7 @@ static void offb_destroy(struct fb_info *info) if (info->screen_base) iounmap(info->screen_base); release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size); + fb_dealloc_cmap(&info->cmap); framebuffer_release(info); } @@ -520,6 +521,7 @@ static void __init offb_init_fb(const char *name, return; out_err: + fb_dealloc_cmap(&info->cmap); iounmap(info->screen_base); out_aper: iounmap(par->cmap_adr);