Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1942711ima; Thu, 25 Oct 2018 07:21:05 -0700 (PDT) X-Google-Smtp-Source: AJdET5d6t7rk3KeTYCKmubwBhaQFkmmLV6XmfPrxsb3DQOMwzkuHvmu5gKTh4KwQdbYyETg0Uq+W X-Received: by 2002:a17:902:3381:: with SMTP id b1-v6mr1693239plc.323.1540477265214; Thu, 25 Oct 2018 07:21:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540477265; cv=none; d=google.com; s=arc-20160816; b=vE00/iBTCfPbvGcvbkydTlUYEERXdncdNGiO4U7HnMLutlM8tIA6ad043EhnEB7N1E pwbOnGA2vZHbrYfQh6pIawl64K23T5cs3bc12fTpTjCKopmj8kfJ8p+UdUcQxSJjfZto Gop2iR7zdDhi3KOHNgfkKCMqxdfY2w9VoUoIhbW046AeAOejx6uzC8G461RS0gt7tyk1 YQzBQwfAZpKSflC/PLgY2566XcSew+BXbOW872AlBPryvGOwfNB7NntYawsO0JwHClIV AGhaBIwmCiEuyv+4P1LzTocqPYp3OPXfCqSoNtXKGAZYuPSGXrQEEGJTZ4xYPrgnh+Sc SByQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=TjPsr84yJmUTlOQBLR68Yf1w+1BGg8tVFNs2fpiB/O4=; b=t6Hn+vADN+Tj4bUwPLeSdW7UXVfAriMDogKuF1TOJ/PK5E2CrkNZzaGRx1evK2G4uT KgiMGb1GcMkhegekjIDx2tzxDJsxRDJ2sXJOXUTAGuiNlNFsYsB2CnIHAMYMdjc1jZX+ 08m+jJcYLjZq0lMf1FvoZjFJs8yVWyipAJpEkwcAHr4ivQc5crvAyUaezJTvk6FA2ux8 naPDR0++jIVPh/4qBIQNqocsWef6tDP9lPT/jj18ynw9iNS3EtZTJY/BpAexMtzANKue 9fxjMaH/p6On8JrvOEUJrtcouvFSUtu9wD+rfEduXuYLl37ZF1hNWW9EbM4b8o5y6AzR BOzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Ttlugx/k"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f35-v6si7995202plh.357.2018.10.25.07.20.19; Thu, 25 Oct 2018 07:21:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Ttlugx/k"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730793AbeJYWwx (ORCPT + 99 others); Thu, 25 Oct 2018 18:52:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:35130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730693AbeJYWww (ORCPT ); Thu, 25 Oct 2018 18:52:52 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CA4402086D; Thu, 25 Oct 2018 14:19:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540477194; bh=hcTycQFxvU2bzPapE8+3QeBmcEqAuqCSGv5HE6+JyF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ttlugx/kY+Q4jzbjtTDLHBWR6OkMKIx7Um3H5sIitm9tYyZTgHRnnirWhkg1rU46q OIros8TpEhv01yd+l4xErr+JVsrMl6etYIEl1mr6Jb1acpMIz67wDkuGWRi9KC/5In naNP5JTt/TNe2uidMt60fUQnHNfftUptLScBVbAE= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Colin Ian King , Tomi Valkeinen , Sasha Levin Subject: [PATCH AUTOSEL 3.18 41/98] fbdev/broadsheetfb: fix memory leak Date: Thu, 25 Oct 2018 10:17:56 -0400 Message-Id: <20181025141853.214051-41-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141853.214051-1-sashal@kernel.org> References: <20181025141853.214051-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit ef6899cdc8608e2f018e590683f04bb04a069704 ] static code analysis from cppcheck reports: [drivers/video/fbdev/broadsheetfb.c:673]: (error) Memory leak: sector_buffer sector_buffer is not being kfree'd on each call to broadsheet_spiflash_rewrite_sector(), so free it. Signed-off-by: Colin Ian King Signed-off-by: Tomi Valkeinen Signed-off-by: Sasha Levin --- drivers/video/fbdev/broadsheetfb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/broadsheetfb.c b/drivers/video/fbdev/broadsheetfb.c index 8556264b16b7..235542f42da9 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 out; } /* 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 out; } /* if we got here we have the full sector that we want to rewrite. */ @@ -665,11 +665,13 @@ 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 out; /* now write it */ err = broadsheet_spiflash_write_sector(par, start_sector_addr, sector_buffer, sector_size); +out: + kfree(sector_buffer); return err; } -- 2.17.1