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: 9546263 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 6276360425 for ; Tue, 31 Jan 2017 00:54:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51BD627FE4 for ; Tue, 31 Jan 2017 00:54:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4604C28285; Tue, 31 Jan 2017 00:54:41 +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.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E07AD27FE4 for ; Tue, 31 Jan 2017 00:54:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754646AbdAaAyk (ORCPT ); Mon, 30 Jan 2017 19:54:40 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:33109 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753724AbdAaAyj (ORCPT ); Mon, 30 Jan 2017 19:54:39 -0500 Received: by mail-pf0-f176.google.com with SMTP id y143so96144453pfb.0 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=Y6931Ss7LbunIdJxT39LzqAnFwSusQlahwlIw0vKgPlsk7qbZxiIstGXV6iIQmMh76 sqpzWdqTrT7WwZhZM0g7RnaMuq8TkNFUWXOdtEVWipN1KhSKH0LIcc5Wld4kBZAKu8Cf LumPtQjrxEYDXCEtqmbTBQPNrC/uad+Xp8ogV2whFcEWSlUUw1Yzmk/CmvXvvnvj11iR bSMcnVz9sOIw2x+bhcTlT8VmevTnqz3akv/O0rMPORyXZNZ4osNCBGFZqjfMQS9lTaSG sy764LgfoZ79ccfL112fAWlVQhOHr7d6XVjfmdd90YKD4z24JhVhqrjvbnnkMKdjYnTp KosQ== X-Gm-Message-State: AIkVDXIIzCbLXwzJpTYrSUTYcQuZwqZPUljGtykN9lK5HW8fUY5sTKnH5r3pyYKLkyottbnF 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: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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)