Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3057179imm; Sun, 1 Jul 2018 11:14:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIxq+C5kQKzNlCUNJU1ObkeEryvB80WpdYdNHZ18Y0DyTaS4Xg23caHBMhXNluDNWex3TsX X-Received: by 2002:a17:902:7d82:: with SMTP id a2-v6mr22908604plm.202.1530468851232; Sun, 01 Jul 2018 11:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530468851; cv=none; d=google.com; s=arc-20160816; b=a4fwYvnKrmca56JbCeU7eM1bWAsjUFQWzyf36UI9CyZhtma4AkJ2ygSlvGEnHjZdOm JBAdAtB9VLCVeDMdNDwEK+AJUaeiVD1M+1uNhi2SzR/1TGApy99lssr1J3E2yr4ZjF/a m+z7VeOeXT4XcdzR2FaAQh8CgJJ/o+6YR4tFwlRmkGoM34qH+vNGUfsxgyAuWCCunUkN KV0KWAIgXE0p4bUBfjykye17z5HKu71qSii5MYLenI+/AgEwEJvZL15auQ0sr8Ysuts9 FFcbdNMETxTT5mtZKwvUolkFF29Qw9IdINIM5tfcjZPYwrEOPK+r7RkePOTKB2gQl31n nRuQ== 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=jrW11P3F9B/xjkFZbFKyPzs2s5HBBcy13qeeYOgxaeE=; b=rELreNVCJ8ORDB02mZHLN/6bMQmwl8eVjgSbLA7sBRYiLvnB9XhjIRVQitlfP7/nfd mImqQd4qAbSlNA49bLA+D/b5mWZhufWDugKHt0K39k24Kk6yqC1/GbYmlVUiVOw2lXkx mnVp7ECcfXJnEFFWnsaR+0mUEs/2aRv8fJmfsXsTsLpBOq1MSuAVjC2cYuq0BU6Q+2ZG Xz3hF26CJqF2C+IJMV0E8FkvTZ7jW+8o3AyUcy1v/FH/08g9TGM+YoFoDDSbcGF9iT1X J+dmc3CALiZdKcAwUaWDv66TT8+/SWjEtEMFCHU2O0BiGnG91wbyNyY4opcbrb7fIaBT EYkg== 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 h4-v6si12108749pgp.490.2018.07.01.11.13.56; Sun, 01 Jul 2018 11:14:11 -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 S965634AbeGASMi (ORCPT + 99 others); Sun, 1 Jul 2018 14:12:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34078 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965213AbeGAQ1T (ORCPT ); Sun, 1 Jul 2018 12:27:19 -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 A70DEAA6; Sun, 1 Jul 2018 16:27:18 +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.9 067/101] rpmsg: smd: do not use mananged resources for endpoints and channels Date: Sun, 1 Jul 2018 18:21:53 +0200 Message-Id: <20180701160759.845013404@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160757.138608453@linuxfoundation.org> References: <20180701160757.138608453@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.9-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 @@ -1006,12 +1006,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); @@ -1061,8 +1061,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); } @@ -1279,13 +1279,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);