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: 10217251 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 40258601C2 for ; Tue, 13 Feb 2018 18:08:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30AC928DD1 for ; Tue, 13 Feb 2018 18:08:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24DB528DE7; Tue, 13 Feb 2018 18:08:25 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AEE828DD1 for ; Tue, 13 Feb 2018 18:08:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965217AbeBMSIX (ORCPT ); Tue, 13 Feb 2018 13:08:23 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35472 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965158AbeBMSIW (ORCPT ); Tue, 13 Feb 2018 13:08:22 -0500 Received: by mail-wm0-f68.google.com with SMTP id r78so17658121wme.0; Tue, 13 Feb 2018 10:08:21 -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=ca8qIBynNRqD29d2WLtiCRGjOzSk9l6AO9n9H/oyyvobtAoT4N0m8xpu36bGGXasEy EISWE3rDIPsgXzrTyXx1tm6fYrhTPUr9tZjmhb9PJqMGFu75TIyxivWR58tBZjwd2mE7 xPVTHh4A7aIUQe23ceLB43s/Smtc4660m1bfS1ZoPzM3cZ87Bvxky1+u4flr6VcO18qF 1rD3h8H/yX2Z5FSHoI2rdjJHa+Vt5I0mWUs+nzo0UijLeMFV1v/BxoA/EyIuzM8YyjGy qjQUiK7OAgE0HpQT7v15VVgTziJwwLeJja0gCpbz2HXdAj1b44t7ft/IT9yU0KGUdJGd dSSw== X-Gm-Message-State: APf1xPAGM4KbZiuAAfz80lZVM60zDki1d3CoVxh6lisCGXiAd0vupvOb 49A4rrvaZX3RGy9cgMAabak= 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 Cc: Mathieu Malaterre , Rob Herring , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org 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 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org 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);