Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3021021ybl; Sun, 2 Feb 2020 12:21:24 -0800 (PST) X-Google-Smtp-Source: APXvYqzrqAMmFmNyfKycDEmAmuHwmJXeQNUNdQ4KhepcbtvfESXaauDAdVLtvbXgTM0OBPzEMwfa X-Received: by 2002:aca:5094:: with SMTP id e142mr12383958oib.101.1580674884415; Sun, 02 Feb 2020 12:21:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580674884; cv=none; d=google.com; s=arc-20160816; b=OlJSrDCzPHNRJYfResSoV67cQDmOqTEW8x9lU1ryUQBj9IVfFpfvS0pAA7hCBTF0Ks hv2mJHNTihGSV9snC0l9sJ8/VhsdAxv+gOghcHHzA16NLYwcqPvffu67qkqh8jHPp1/T dnxFgJzTRKojbyJ251jVKKtseVybGW6zFCPCYUzJEwlqRebCnhYmalVkUN0jqq2IJ8c0 oGxBQGFTB0iMxSAXcu56jfULzbpneGwM5yOdgL48DV8s748i4AjwC/Qjsshzdhyxl0E7 lYbF5hbd020OEXZ8spDvR4/SGHbDgE5luh50+XgXNxihhbGkEoxgR+apIaRf3VAazWI9 E/qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Ex7VzESjDb/0KDf5v73+dcAWmJ7vruqjhEQHHsrKlzI=; b=S6uFiD5I84S02KoFFYJ+0sIxlFoCTwTsUUIK+tEZPV+YHTTLYfll9h0Do4npTL8nma c9hCS+2yH29tXsyh6uKXhRveBQpDTwUb2+q4rSUZKsNpYTQRwU/8cpKb70pKHYdxtbUo PbZxdAOjG5oHKBb4z/aJFCsGQ3ZHi1NX/vTSq8rcfAa+f0NhOKiEPdOoVLqH+MXusNfn iBYViBflrA/8bUDT50P2FtDFXI55IONx9bbJzXu6xAVMJRUYU+r88G+TfZgVEOn3Rcqm 2yUatfPepQNl5KwD6dig46x97ix02EuVsIB4rLUEfEFdgklaDCTUK4Xa7oyybEn6IPGb 9NPQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r67si1537083oie.145.2020.02.02.12.20.59; Sun, 02 Feb 2020 12:21:24 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727088AbgBBUTa (ORCPT + 99 others); Sun, 2 Feb 2020 15:19:30 -0500 Received: from smtp06.smtpout.orange.fr ([80.12.242.128]:56505 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726893AbgBBUTa (ORCPT ); Sun, 2 Feb 2020 15:19:30 -0500 Received: from localhost.localdomain ([93.22.149.209]) by mwinf5d11 with ME id xwKT210044XJket03wKTjT; Sun, 02 Feb 2020 21:19:28 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 02 Feb 2020 21:19:28 +0100 X-ME-IP: 93.22.149.209 From: Christophe JAILLET To: ralf@linux-mips.org, paulburton@kernel.org Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] MIPS: VPE: Fix a double free and a memory leak in 'release_vpe()' Date: Sun, 2 Feb 2020 21:19:22 +0100 Message-Id: <20200202201922.22852-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pointer on the memory allocated by 'alloc_progmem()' is stored in 'v->load_addr'. So this is this memory that should be freed by 'release_progmem()'. 'release_progmem()' is only a call to 'kfree()'. With the current code, there is both a double free and a memory leak. Fix it by passing the correct pointer to 'release_progmem()'. Fixes: e01402b115ccc ("More AP / SP bits for the 34K, the Malta bits and things. Still wants") Signed-off-by: Christophe JAILLET --- Un-tested The 'if (v->load_addr)' looks also redundant, but, well, the code is old and I feel lazy tonight to send another patch for only that. --- arch/mips/kernel/vpe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c index 6176b9acba95..d0d832ab3d3b 100644 --- a/arch/mips/kernel/vpe.c +++ b/arch/mips/kernel/vpe.c @@ -134,7 +134,7 @@ void release_vpe(struct vpe *v) { list_del(&v->list); if (v->load_addr) - release_progmem(v); + release_progmem(v->load_addr); kfree(v); } -- 2.20.1