From patchwork Sun Jun 12 15:03:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 9171539 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 328126044F for ; Sun, 12 Jun 2016 15:04:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26FF925EF7 for ; Sun, 12 Jun 2016 15:04:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B4D927C0C; Sun, 12 Jun 2016 15:04:13 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B67CB25EF7 for ; Sun, 12 Jun 2016 15:04:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A07516E0F7; Sun, 12 Jun 2016 15:04:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4CE656E0F7 for ; Sun, 12 Jun 2016 15:04:04 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id n184so9230349wmn.1 for ; Sun, 12 Jun 2016 08:04:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=6/p1ugyg5tQRLsdBOHcI1+bwzkrUT/Pya4yCXKXFCEQ=; b=w1QkNoeRyyY53yuGCGHb8gASXtPBfRQBAJieCwYjG2kKkh40VlhxjGmRc4lnGJ8YYW J/i6+FOBp+0Bfh8Foj4mBERCmQDAfr1R481QYum8aqUsvJc4wYsSJZlZ/odnP6ipAb/M AIgtittJ30jM8dx6D7UZcMakJ4sR/QRxcTDXwKL784Yro1LQJsuYlIIjOD602aMlx2Vr LpXQii3SkihQmoaXig3sQusfeJOfPQB/JkztNe9DSbptuAzmA/Hk38IhAAT/1jwjNNQW +taPhHDjx9dAOFMPB7oITQUWFaDq7dSshdGFFV+BdNvnYMGNvuiZI23/K5S5vYiTNgiz QWLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6/p1ugyg5tQRLsdBOHcI1+bwzkrUT/Pya4yCXKXFCEQ=; b=NBXkpYr5lUtz3NrpSmmeKvlOM8JuCcHwPeTEadIOkyOdtszEkDM2NGjd5TfIuzfKeC 4dHozWGyhOm6YWSvEcsVdXeGJYC52dFKbnPr9Dsx5j+pw9hr6WjOBtHBYImaOg2UIoJ/ LsiDkMRHfPjQbqJMczVsMsPrRrGdJ/MKyoxDoYel3/6Yp7TD4CzKoObMaM93ywcRh2uR 6EHnmbIa3c9UI4Lk+V1UPg3rtadpl85nAfUPPVQ29Gc0Pioo7l/meI9LbG8wrgwHFJFG vAnWSRZEd6+LpeNTdSQb+dZdIAJygF+pT5ugNgLuWRMbEaer04bnLeqOUw9vhmliTase xaAg== X-Gm-Message-State: ALyK8tJqYfdjdA45JQS5rE7dSlTJUYWJROELile++IF944ZbO4hs1EepCRTE7DB148DrnA== X-Received: by 10.28.215.139 with SMTP id o133mr7247713wmg.74.1465743842471; Sun, 12 Jun 2016 08:04:02 -0700 (PDT) Received: from sudip-laptop.lan (234.98.208.46.dyn.plus.net. [46.208.98.234]) by smtp.gmail.com with ESMTPSA id x194sm9463708wmf.13.2016.06.12.08.04.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Jun 2016 08:04:01 -0700 (PDT) From: Sudip Mukherjee To: David Airlie , Daniel Vetter Subject: [PATCH] drm: fb: cma: fix memory leak Date: Sun, 12 Jun 2016 16:03:56 +0100 Message-Id: <1465743836-6228-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sudip Mukherjee X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We may have a situation that the memory allocation for fbdefio fails and then the allocation for fbops may succeed as some memory has been freed somewhere. Lets free fbops also to face these rare situtation. Since kfree can handle arguments as NULL, there should not be any problem in calling both the kfree(). Signed-off-by: Sudip Mukherjee --- drivers/gpu/drm/drm_fb_cma_helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index 2e7ef0b..c0b0c71 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -346,6 +346,7 @@ static int drm_fbdev_cma_defio_init(struct fb_info *fbi, fbops = kzalloc(sizeof(*fbops), GFP_KERNEL); if (!fbdefio || !fbops) { kfree(fbdefio); + kfree(fbops); return -ENOMEM; }