Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2994655imm; Sun, 1 Jul 2018 09:56:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJx0vq01C9fPaH/otbCnshjxe9td6QCP2piCPBW0YWbFF+OgCzY3Ul0SSsypluJjXgotY0B X-Received: by 2002:a17:902:722:: with SMTP id 31-v6mr23192044pli.3.1530464200106; Sun, 01 Jul 2018 09:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464200; cv=none; d=google.com; s=arc-20160816; b=f58eWZV0FVHjn9NN68uzssJRDaOIV1eKNN7HnEwrqJjgQupunrSu6RW86xUDUKRhKa qQoI3uXmraLcsnmwjjHoUWn6uA7QDbaOHebwZWMWTk4xHigIFlYRCEkXHp8tQv6FL2sO ux0bUsr7EMbnWn7eBIJVBfTDKF63PmXQhWwt688DuhHuyRxTDh0v2P9DS45F9x2uFJBj qZONj8Hz62M5HnePY0dOTjOdWzTa2dOKlZziQVNvxVstfDHEQHrfyYWewrfpx4+GPJ9f mtDhjPiD2+F5Ozg3xA2Qk1UJkway6EhOHplBi9C92KDs6GzLtNmOIE2n70KDho8jKh3N pRCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=6z4c8f3MGRFNpqrY5HBbJkjE3hR6kE4OyVjOc9WOym8=; b=dKl2sK2LglHYC8N3whTPY1y8SJyT+sex38cXQTK0UsW8z0/XizCZZDtmaDk3sOlsK5 xsgiqSkIdlr4U5gtotV4vjkBmK9eRRrWysTwWSSC9R4/mUbnkfh7I6HZrdC08SDzhnxs royp4s+vTbIa1AZZiR0nh5pJ9zZvx3kFoa0VifV3lagZOU//de2j0qJJCiqwg0OsRFn8 hHP6xGfzZLRjk040ruzxCdFF/ahyjKZCaqZzvyPLc5cwhMnax8teOC8UO3ciYIxLRAkP XisVqgmU+v1zsbgNELm53LScc63RcXaCE5V/ITCdwiEvLxM9rbZHn1XL1lF4YwCmrMve 6/2A== 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 y20-v6si13996509pfm.186.2018.07.01.09.56.25; Sun, 01 Jul 2018 09:56:40 -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; 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 S934045AbeGAQpK (ORCPT + 99 others); Sun, 1 Jul 2018 12:45:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38160 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932883AbeGAQpG (ORCPT ); Sun, 1 Jul 2018 12:45:06 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E1D72A73; Sun, 1 Jul 2018 16:45:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Kandagatla , Bjorn Andersson Subject: [PATCH 4.17 151/220] rpmsg: smd: do not use mananged resources for endpoints and channels Date: Sun, 1 Jul 2018 18:22:55 +0200 Message-Id: <20180701160914.607277239@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Srinivas Kandagatla commit 4a2e84c6ed85434ce7843e4844b4d3263f7e233b upstream. All the managed resources would be freed by the time release function is invoked. Handling such memory in qcom_smd_edge_release() would do bad things. Found this issue while testing Audio usecase where the dsp is started up and shutdown in a loop. This patch fixes this issue by using simple kzalloc for allocating channel->name and channel which is then freed in qcom_smd_edge_release(). Without this patch restarting a remoteproc would crash the system. Fixes: 53e2822e56c7 ("rpmsg: Introduce Qualcomm SMD backend") Cc: Signed-off-by: Srinivas Kandagatla Signed-off-by: Bjorn Andersson Signed-off-by: Greg Kroah-Hartman --- drivers/rpmsg/qcom_smd.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -1100,12 +1100,12 @@ static struct qcom_smd_channel *qcom_smd void *info; int ret; - channel = devm_kzalloc(&edge->dev, sizeof(*channel), GFP_KERNEL); + channel = kzalloc(sizeof(*channel), GFP_KERNEL); if (!channel) return ERR_PTR(-ENOMEM); channel->edge = edge; - channel->name = devm_kstrdup(&edge->dev, name, GFP_KERNEL); + channel->name = kstrdup(name, GFP_KERNEL); if (!channel->name) return ERR_PTR(-ENOMEM); @@ -1156,8 +1156,8 @@ static struct qcom_smd_channel *qcom_smd return channel; free_name_and_channel: - devm_kfree(&edge->dev, channel->name); - devm_kfree(&edge->dev, channel); + kfree(channel->name); + kfree(channel); return ERR_PTR(ret); } @@ -1378,13 +1378,13 @@ static int qcom_smd_parse_edge(struct de */ static void qcom_smd_edge_release(struct device *dev) { - struct qcom_smd_channel *channel; + struct qcom_smd_channel *channel, *tmp; struct qcom_smd_edge *edge = to_smd_edge(dev); - list_for_each_entry(channel, &edge->channels, list) { - SET_RX_CHANNEL_INFO(channel, state, SMD_CHANNEL_CLOSED); - SET_RX_CHANNEL_INFO(channel, head, 0); - SET_RX_CHANNEL_INFO(channel, tail, 0); + list_for_each_entry_safe(channel, tmp, &edge->channels, list) { + list_del(&channel->list); + kfree(channel->name); + kfree(channel); } kfree(edge);