From patchwork Wed Jul 2 21:31:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rickard Strandqvist X-Patchwork-Id: 4468041 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 697DFBEEAA for ; Wed, 2 Jul 2014 21:30:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8ADD320384 for ; Wed, 2 Jul 2014 21:30:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E1A512024F for ; Wed, 2 Jul 2014 21:30:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753293AbaGBVaB (ORCPT ); Wed, 2 Jul 2014 17:30:01 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:59239 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754010AbaGBVaA (ORCPT ); Wed, 2 Jul 2014 17:30:00 -0400 Received: by mail-lb0-f174.google.com with SMTP id u10so8415411lbd.19 for ; Wed, 02 Jul 2014 14:29:58 -0700 (PDT) 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=TPv3CZoV6IMfMxzwoFlaDBMA44Kk90eBZQuPFg/bCEA=; b=ZSoNx39hNQJKZEsdSRGtug0pz5KNd9JQKfaQKJchRrZkn9BaMqoE8Gi7+vZvAKOvUO aSgJ6uavpbUeX4oq8Yos8HqmJ+jXMlMovD9aTGIIyzDEavpnscsg9N//C93zZ5VOKSRE oLOrzFEb70lXACZGGaw2ZTCDijXwt3Nh2dArOirVtZuUjEpH0RCWbB2D75bHUxlDGEqJ 04VfgY6KaO4fKNDpFn6glWcO6xiZAm/ADKsWxrCnWGFDjEmaKrELMh+1R0okTZBXjSfF O337E09dc50dI1eWT+eOvwLN9wNFPMUBPN76/a6dWIeQk3BhjOhtyLs2vDRxzehigS8B rFKw== X-Gm-Message-State: ALoCoQkKAkIGBQSkm57eihkYNp9DOaerSPsYBmqfBKGhVC8sG4NEp/EVQ83PUvZpjPB/hmftd2B5 X-Received: by 10.112.52.167 with SMTP id u7mr288588lbo.28.1404336598731; Wed, 02 Jul 2014 14:29:58 -0700 (PDT) Received: from localhost.localdomain (h-245-62.a218.priv.bahnhof.se. [85.24.245.62]) by mx.google.com with ESMTPSA id c3sm12391018laa.33.2014.07.02.14.29.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jul 2014 14:29:57 -0700 (PDT) From: Rickard Strandqvist To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen Cc: Rickard Strandqvist , Jingoo Han , Daniel Vetter , Joe Perches , Hanjun Guo , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] video: fbdev: broadsheetfb.c: Fix a memory leak Date: Wed, 2 Jul 2014 23:31:12 +0200 Message-Id: <1404336673-6099-1-git-send-email-rickard_strandqvist@spectrumdigital.se> X-Mailer: git-send-email 1.7.10.4 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix a memory leak. This was found using a static code analysis program called cppcheck Signed-off-by: Rickard Strandqvist --- drivers/video/fbdev/broadsheetfb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/broadsheetfb.c b/drivers/video/fbdev/broadsheetfb.c index 8556264..526e5e84 100644 --- a/drivers/video/fbdev/broadsheetfb.c +++ b/drivers/video/fbdev/broadsheetfb.c @@ -636,7 +636,7 @@ static int broadsheet_spiflash_rewrite_sector(struct broadsheetfb_par *par, err = broadsheet_spiflash_read_range(par, start_sector_addr, data_start_addr, sector_buffer); if (err) - return err; + goto end_release; } /* now we copy our data into the right place in the sector buffer */ @@ -657,7 +657,7 @@ static int broadsheet_spiflash_rewrite_sector(struct broadsheetfb_par *par, err = broadsheet_spiflash_read_range(par, tail_start_addr, tail_len, sector_buffer + tail_start_addr); if (err) - return err; + goto end_release; } /* if we got here we have the full sector that we want to rewrite. */ @@ -665,11 +665,14 @@ static int broadsheet_spiflash_rewrite_sector(struct broadsheetfb_par *par, /* first erase the sector */ err = broadsheet_spiflash_erase_sector(par, start_sector_addr); if (err) - return err; + goto end_release; /* now write it */ err = broadsheet_spiflash_write_sector(par, start_sector_addr, sector_buffer, sector_size); + +end_release: + kfree(sector_buffer); return err; }