From patchwork Mon Jan 30 16:55:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 92926 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1705299qgi; Mon, 30 Jan 2017 16:54:45 -0800 (PST) X-Received: by 10.99.173.66 with SMTP id y2mr15777684pgo.35.1485824085154; Mon, 30 Jan 2017 16:54:45 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p126si14244953pfg.209.2017.01.30.16.54.44; Mon, 30 Jan 2017 16:54:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754634AbdAaAyk (ORCPT + 3 others); Mon, 30 Jan 2017 19:54:40 -0500 Received: from mail-pf0-f181.google.com ([209.85.192.181]:36035 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753696AbdAaAyj (ORCPT ); Mon, 30 Jan 2017 19:54:39 -0500 Received: by mail-pf0-f181.google.com with SMTP id 189so96289672pfu.3 for ; Mon, 30 Jan 2017 16:54:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=95ug/R2mOpYpOE+owIXTiWiIvfzuqrr9/KJeSoTkO/c=; b=RVA6kBAswmFeQcSVa+hN+N0zKXILh4iRI3jxXQu4Mju2r0Gjo2wTZu9fCy2CZ/QIZC b3MERBI3DmEH0cBIhJBIRH3alGDkgOyNwPof2qOSWEREfadAkpisFEI9zxs9stN/iA8J bIaxF9ZfvSgBCWHCHHJ9gj+FtfwlcVj2GA/gI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=95ug/R2mOpYpOE+owIXTiWiIvfzuqrr9/KJeSoTkO/c=; b=RxwQ4GDCHwJPd42OGoipIrE3Y1l3u9sNKGHmCXVSnbjfKpQw7Q/9jt+cb2CHrR46Wk mWQJb40klLtp/IPtBV6KWg2HFYTsy3pFqF68FU0+gXX49btRp7pL77upPcSskfu2jf1p dOPEDjSLRn7x1hvjjwayH/a8ySHyUWRXBuHt0MGfUr+S75WQgU1ONhRihaT4ncloa3jh EhWvr8B+VIZNH5iUssCGIb7fKTXnn2kbLkCV7hmgwMGUJN0NbgGqUYXpLp/AGnlO24hl amrDXr/687rzfq3YmT71g86WqJTt25ubFLjqrk8D5Od4f9p4gIwBadqLxpFEHvStL2CI ZPaQ== X-Gm-Message-State: AIkVDXL4T8ZDTYhHXfQ1zp7K45/FAqBsDquuGEsSya5RjNGT1IgVkPJ2vW01gDnk1ycC/OuS X-Received: by 10.84.237.22 with SMTP id s22mr35862559plk.145.1485824078731; Mon, 30 Jan 2017 16:54:38 -0800 (PST) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id d78sm35466933pfb.43.2017.01.30.16.54.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jan 2017 16:54:37 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andy Gross , stable@vger.kernel.org Subject: [PATCH 2/5] remoteproc: qcom: mdt_loader: Don't overwrite firmware object Date: Mon, 30 Jan 2017 08:55:44 -0800 Message-Id: <20170130165547.4344-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170130165547.4344-1-bjorn.andersson@linaro.org> References: <20170130165547.4344-1-bjorn.andersson@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The "fw" firmware object is passed from the remoteproc core and should not be overwritten, as that results in leaked buffers and a double free of the the last firmware object. Fixes: 051fb70fd4ea ("remoteproc: qcom: Driver for the self-authenticating Hexagon v5") Cc: stable@vger.kernel.org Signed-off-by: Bjorn Andersson --- drivers/remoteproc/qcom_mdt_loader.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/remoteproc/qcom_mdt_loader.c b/drivers/remoteproc/qcom_mdt_loader.c index 2ff18cd6c096..2393398f63ea 100644 --- a/drivers/remoteproc/qcom_mdt_loader.c +++ b/drivers/remoteproc/qcom_mdt_loader.c @@ -116,6 +116,7 @@ int qcom_mdt_load(struct rproc *rproc, const struct elf32_phdr *phdrs; const struct elf32_phdr *phdr; const struct elf32_hdr *ehdr; + const struct firmware *seg_fw; size_t fw_name_len; char *fw_name; void *ptr; @@ -154,16 +155,16 @@ int qcom_mdt_load(struct rproc *rproc, if (phdr->p_filesz) { sprintf(fw_name + fw_name_len - 3, "b%02d", i); - ret = request_firmware(&fw, fw_name, &rproc->dev); + ret = request_firmware(&seg_fw, fw_name, &rproc->dev); if (ret) { dev_err(&rproc->dev, "failed to load %s\n", fw_name); break; } - memcpy(ptr, fw->data, fw->size); + memcpy(ptr, seg_fw->data, seg_fw->size); - release_firmware(fw); + release_firmware(seg_fw); } if (phdr->p_memsz > phdr->p_filesz)