From patchwork Mon Jun 4 09:39:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 137622 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1289357lji; Mon, 4 Jun 2018 02:41:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKlDW1DFHBI1KPK4rm0T10ESTYvMP8zdFNSjFfeNAwKC2RGQLgaEpn4Sk52scGpvO4vumZh X-Received: by 2002:a17:902:8c81:: with SMTP id t1-v6mr20863421plo.310.1528105274790; Mon, 04 Jun 2018 02:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528105274; cv=none; d=google.com; s=arc-20160816; b=XBRrlXucG76eO77I9J+QY70SIGPV6GU302C6ZjmVEiuE+ryvqNFaxXexPscm4+qnXY npfAU70P/AnAhZ1WD6gw3uyYPkyl7El2wZlxp9UCbcchmiT274H4Rop/9Ti2OneXDygI xXJlWn07R1t+5teZAXCf7Scxut6J7Rb2IR2+mryhwz5MTy2y5pzTNI+aR/ML9XuC9XyX ol6r8tppsCRzi2z5ypi7LV4gVdENNzQW/ui+wGy/1YLNvIgsfaFsB1lZE58JKtBPX5+6 mCByBNu9bhd76i+YSFqRE77gmQAswNTPbbhj3FyAHBeG+nGYmuTlASQ/+BFk4pZ0vWdP 1LSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=HSmS4R9NcyX61okIafoihDvvU8AZ0fAjqT+5yWZyCX0=; b=J101t0ekYkxJeDCHUZIr7gr0vyX9KUHuUsOBoCXIuy1UM9tCWChoCi/2HppA84H7n6 rP5dk8+7hM6zZj5VYNDJ+4HQPVuGDqn1u2ivVTn9o0XLPYxd4MBuiXogEO7t7n0eydAi K2K5N2MHdTaMJZSMyCAfeZm8W1xn6Vv+Trdagptuc8kxQ5Vtepqz6jBRzEd4YSCdAeL+ juAjFaINwDFHcHCcaW364HO1PPDPpNvv1HO46KbevUAfeESB8jV3O8C1J6396Jyhvyid B07FqdEu2Uxb1SBznbux0B40dveVmdlIzJlcAuxmQ1j/4jJKNUDM6xG6FYV033YVXxky Ne5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LjVevsbx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i4-v6si581696pgq.202.2018.06.04.02.41.14; Mon, 04 Jun 2018 02:41:14 -0700 (PDT) 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=pass header.i=@linaro.org header.s=google header.b=LjVevsbx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751970AbeFDJlN (ORCPT + 13 others); Mon, 4 Jun 2018 05:41:13 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:52575 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751930AbeFDJlM (ORCPT ); Mon, 4 Jun 2018 05:41:12 -0400 Received: by mail-wm0-f68.google.com with SMTP id p126-v6so5293664wmb.2 for ; Mon, 04 Jun 2018 02:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=HSmS4R9NcyX61okIafoihDvvU8AZ0fAjqT+5yWZyCX0=; b=LjVevsbxygEWcgAQt5zR+lueMlrVySRjeVhSRPqMF3OipIqJGJNXEZJv8Y1OX+1kKh RgS8opln06tgnRl9ba2ZbRrVvpgtiySQA/m+jvDA9PoVyG5JU8td3Cw3ronZtewyUcuv SNRZJ7f5L3Vf2ir1Dt/38pLFM2+QbpdYuGqko= 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; bh=HSmS4R9NcyX61okIafoihDvvU8AZ0fAjqT+5yWZyCX0=; b=qj0Rdz0nIdZCo4I+JgdN8E+RNa11EbX5jWTNreZ4I6XJvwkCcF3uxE7rYKitstqPl0 i7XW2pZqOFx/FqTUt54pl6E4nyb1dIkI26bk12C8ygHoV4fJCZMr/5U1YpeR64j95Ys4 uHuRcLJPCCBhBej9ICvpFkmgK+yRjs1XiPPmQJ/1ahqDceTZ3CBbv3FxGjEAozBcs15l uESDnGfgIOw8rqyEmLkdrbe+qicKjj1L24xnkX5mEGISV4uCrt3L2KyaLl28RTQdOG4E e1xMbpAEHr1q7LX3hbT42WjymvywMVHXMfLw4sCmi/rlXVD1LUXDEeMlaK5TZ6/3WL0q 6V1Q== X-Gm-Message-State: APt69E1tqXwv/E3Uiui2UBOSuoypa+3IcslHrYYTVeBg7AOMbn1FZdOk cw98nBGYvgGm+dDESp7XkgnXcQ== X-Received: by 2002:a1c:3448:: with SMTP id b69-v6mr1321273wma.0.1528105271218; Mon, 04 Jun 2018 02:41:11 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id f24-v6sm7133499wmc.0.2018.06.04.02.41.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Jun 2018 02:41:10 -0700 (PDT) From: Srinivas Kandagatla To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, bgoswami@codeaurora.org, linux-kernel@vger.kernel.org, rohkumar@qti.qualcomm.com, Srinivas Kandagatla , stable@vger.kernel.org Subject: [PATCH v2] rpmsg: smd: do not use mananged resources for endpoints and channels Date: Mon, 4 Jun 2018 10:39:01 +0100 Message-Id: <20180604093901.6963-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 --- drivers/rpmsg/qcom_smd.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.16.2 diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index 5ce9bf7b897d..f63adcd95eb0 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -1100,12 +1100,12 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed 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_create_channel(struct qcom_smd_edge *ed 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 device *dev, */ 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);