From patchwork Wed Sep 18 17:19:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 173986 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2731881ill; Wed, 18 Sep 2019 10:19:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsaNWNCVY0TxzE3JozovJs54TDZHdtb7o5AtMtrmKyP31wZZ95dSnhWHE4omF2u3BxpYGq X-Received: by 2002:a17:906:7e56:: with SMTP id z22mr8295189ejr.294.1568827169193; Wed, 18 Sep 2019 10:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568827169; cv=none; d=google.com; s=arc-20160816; b=kIarh0ASwsXXc47vIMUYL8iuXdO5o43uKwB0VCXntDPzaMAlajodMShs01QMdmKI2O yomMHzMRMAB4/gH3uJ6ruZOTDW2QOFbczusCShrPflsxB3oNnzB8AnzhKIYtdHEGsdSW /nXwziZhhGGJKBNCx5xmTHIGFb4Kshk+37oqTQkifFtL2I7maP5hzWCq2852suLci10W iq4okWuyz8KwWm2K3xoZuK6WF3uQ7aqhelskv2VyXNScLVfgXkx234qGfmQkPfUfObbm p2Jw51FA9utBQmvttY2bxNfVEt3rVbsWuuH4MPSwrRrvFZ/zXU780QankKyzmdspyBSD 1K9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=VwSAewYHioEBjS31iqIfRjVrZyDonRdWcj1Y+TfsqH4=; b=P4K7DBDSdCoJ8xq3sBmllLCPHm2FLYxv0EY2bo5z6wNBod8WkjE3gDFDwx7nxGGcTD y5Y84eKaTSyaDE1IVWdSuvNsqDQ2/nj/MrAU/n9XLxZdN1TYiBaOlpkDuParP3CJhxdI SMVgsF0evIM9zi/rBUvhc5KpKLBWKwrsW+XKTtpmewb0HApeb7FgIkz41VNDqgbBSe03 njyATt0A1AxXvowM8Quocih4mmk06lEbemIFjfnkQ4llFM8bVswA32bMKUysR5l69SEU fWsUdIeTY9N7nf93vEGwuDXvgdqFXSz0Lymp4QpHCYMc8ASBkWYFFv9g8ttfqkKP4fqB Mxtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rO9i/cqL"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 om23si3416800ejb.194.2019.09.18.10.19.29; Wed, 18 Sep 2019 10:19:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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="rO9i/cqL"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1732114AbfIRRT0 (ORCPT + 15 others); Wed, 18 Sep 2019 13:19:26 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36195 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732110AbfIRRTY (ORCPT ); Wed, 18 Sep 2019 13:19:24 -0400 Received: by mail-pf1-f194.google.com with SMTP id y22so426265pfr.3 for ; Wed, 18 Sep 2019 10:19:24 -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:in-reply-to:references; bh=VwSAewYHioEBjS31iqIfRjVrZyDonRdWcj1Y+TfsqH4=; b=rO9i/cqLekYgyKdKCnFYjAL4R/QkPCECSyUyb7g2A+JKQKpKGHGHs2JQa91AMbG/2w 1lED6OUbgkoFnKNsS8sAuVKoGcJ/HX7iMbXflFVJP+G0Eoh2jir2EAjBir/87kMiVIbH TGN86ho4VviITmkJju5fHnGtLVyX20eLopp2OR9zx/XrG+lbFUgF9ho8nWFvUVmMOosg ztCiiJk0oz5dDSW0jP1/X7SxOt1poyhGRX1OYbu824rVveyFMp8Afqmdm2rA7sVRW6qe yIIF8ArmWEbZl7z3D7gYV6yBb+uq9Yj6DuuVk/BKO+JoxTbwTZEfgolB3XIWu87dAOFJ 5AUg== 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=VwSAewYHioEBjS31iqIfRjVrZyDonRdWcj1Y+TfsqH4=; b=IWoQAkG8gdw3faBNO0v4uVMb9rY5Q9Z1G3QKs+id3C/EJDLnHJakdGSv0y4bVYWT73 /DinCKacinTtp1rWpr8DArY6Wskz2wJkD8khP+nf3XYe/QIHkUMegQV1fc+vwlKO57n7 7ewImVMFhwM+/EslzjzUO+nr2+iyaGMSe26OgfvXw+MMYuYpI48Oz2dIa2QYIvLCp2Q5 lOd6jdVXwyId+ypGS/1+KrjPmlyyv6yfIjyIljlPmiYs5hl0RUFYxLl67l4UPOSQrf32 KmNFMI4cqD3iya5R+G11a2yPNErxJY70xiwSakvMwrX2Q1L5HBWUURR9axn8apnS46rX CiQg== X-Gm-Message-State: APjAAAWKGnCBH5BhvuEuXa5jO57+7nxySp8ThOJJIs2BVfZCac/sUe1v j0vMlzLp0Rs8x170BVUIL6Laog== X-Received: by 2002:a65:6557:: with SMTP id a23mr4976164pgw.439.1568827163712; Wed, 18 Sep 2019 10:19:23 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id y4sm2614981pjn.19.2019.09.18.10.19.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Sep 2019 10:19:23 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Srinivas Kandagatla , Jorge Ramirez Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 3/6] rpmsg: glink: Put an extra reference during cleanup Date: Wed, 18 Sep 2019 10:19:13 -0700 Message-Id: <20190918171916.4039-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190918171916.4039-1-bjorn.andersson@linaro.org> References: <20190918171916.4039-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Chris Lew In a remote processor crash scenario, there is no guarantee the remote processor sent close requests before it went into a bad state. Remove the reference that is normally handled by the close command in the so channel resources can be released. Fixes: b4f8e52b89f6 ("rpmsg: Introduce Qualcomm RPM glink driver") Cc: stable@vger.kernel.org Signed-off-by: Chris Lew Reported-by: Srinivas Kandagatla Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_glink_native.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.18.0 diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 72ed671f5dcd..21fd2ae5f7f1 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1641,6 +1641,10 @@ void qcom_glink_native_remove(struct qcom_glink *glink) idr_for_each_entry(&glink->lcids, channel, cid) kref_put(&channel->refcount, qcom_glink_channel_release); + /* Release any defunct local channels, waiting for close-req */ + idr_for_each_entry(&glink->rcids, channel, cid) + kref_put(&channel->refcount, qcom_glink_channel_release); + idr_destroy(&glink->lcids); idr_destroy(&glink->rcids); spin_unlock_irqrestore(&glink->idr_lock, flags); From patchwork Wed Sep 18 17:19:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 173988 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2731982ill; Wed, 18 Sep 2019 10:19:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqaSiwkRObbDMGpXduhKDwZSAFqAgSK7Hlrh6x07Wi8K29M1LmNQJoSq+kwJEo2tlrhoby X-Received: by 2002:a17:906:6bd5:: with SMTP id t21mr9308253ejs.128.1568827174342; Wed, 18 Sep 2019 10:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568827174; cv=none; d=google.com; s=arc-20160816; b=bz0N86i3oH1fvNh7tIlL2GeZPMvMmKA8NOqqQkLQOREhhEmUkwX3FHbwXplzZpmT4p lFFG26ogtlC2Z97h7eUtODG7rIyU1cecQMklqLMy1Mf4leu2bFwXuCX6Nay3TcnArvy4 sxXGwuYO9V15Nw2zappeQVrlKVdEO4uL/tm4sXz5AdVpRrFzjVYvg6cvEILRV4G51oCs DE4FOqw9r8bFVabhyNzMPxh+uNIcPl0YI40ww2Qxx/vg2NwugelA9a8Z4s+RYqpJu/ua 8Z9ZRPkzf8Oguyj6Gj9BuXKAGFort3awQTjDgnHwzxsyDGONedcPF3u8U6+rOb4FhbEk CnIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Zted6byoUjfvi72VSDIhM8pesVU1cPbkC92rYkmfs6k=; b=yoRl07HsNuyAvncIDUlABEcJ9uYFqa8AU2dRwRgXodLFAX1k8S2khO6N54MhRTbFIz bOG5KlNwfi6eY4OiCmBeUGS3lI/1XCgge54KZN9oj8kng6FpqG7Lxxnhfr0MuALrgrdX X5B5vX8y1LAEBNpEG8diAYTzJEpk4nSko0Ip/IrSD9L0pc+akA/9Ub2hMrmuvco2SeWF VBjt5ewLuu2/WwfhUYB5Vd6v0Rw845CeynkuUZ8KIP9bXtVb6EYdeeAl//wu9pbW7xR2 Hign1o1mJ6XOpewxgKGbWuoV4mbHqsh7hwzEX8ju/2LvjdGdGoUqHTktzru5qVcOkvcz m9Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rYhSObq4; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 r18si1604702ejr.189.2019.09.18.10.19.34; Wed, 18 Sep 2019 10:19:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=rYhSObq4; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1732143AbfIRRT2 (ORCPT + 15 others); Wed, 18 Sep 2019 13:19:28 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:34235 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732129AbfIRRT1 (ORCPT ); Wed, 18 Sep 2019 13:19:27 -0400 Received: by mail-pl1-f196.google.com with SMTP id d3so277481plr.1 for ; Wed, 18 Sep 2019 10:19:26 -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:in-reply-to:references; bh=Zted6byoUjfvi72VSDIhM8pesVU1cPbkC92rYkmfs6k=; b=rYhSObq4evGVg356bza5zIWCf7uvuBbpf4HCEDLaZ/lBqNwdVQZDZZoJiUCg5d1A6b cmF677BmCdEDLLgmJKuII4SBexOEnJwmuqvItJo7DaeE8IDlhRrFU1xI9PNu54Am5Nsq 8O0JANibva5B7rlPn5iBN4STl/6PWnmXYTPwCkim8kiqhcs1bBXjWFga1BqcQvhJ+3jx 6H3jIg+C1VUq53LrNHDo9jwI4WZQH3nT2sDwFIIyNQGKmh9nDz2jmGUAUZmF6LsTpOp4 0UBsPBSdsE1TcqagQJhKslYjT7t1M6t8FJAsbCKRKUeRT04AaniPiAI5g229tX0I+wvt tjtw== 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=Zted6byoUjfvi72VSDIhM8pesVU1cPbkC92rYkmfs6k=; b=kTWbwXOgXwLfBV95BBPNPLmnfN9sl99ekotDMgonBlZKFohmlkdtrisGfM382G0Fk7 HqF4tudUfzfenT6Yhqa1AIcI5IM48+ssE9P7qG/n8kF+eqfPnRK7emrGD4kE5frD7YVx ddlRDvScH914rMU9I01uKL0QK0UDF6Qv4r3y6Hyxhp0XR3rBclCRCtMbj9IWxzcr44Ah p30LOPovcuOpOv6THc0zProdDwlSgbCvRe2cwYyu6kuZnbeJK5qR9ftHIfAOYN1szhQ4 NYmTiFZ3Oo+r7BngJ7q1YJVqusEfOpJcyocBulhCRK8XmiIiKdCDX7y6BFkZ+lMcIF5w EuSw== X-Gm-Message-State: APjAAAXSxcAqbaAPEe2gDZakaqdlYYKo/QmXXXp7tAt8Xn5C9wTU4bZk lH+dq6uTx8q1Y5+3g6lCEZSPzQ== X-Received: by 2002:a17:902:b497:: with SMTP id y23mr5286203plr.201.1568827166359; Wed, 18 Sep 2019 10:19:26 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id y4sm2614981pjn.19.2019.09.18.10.19.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Sep 2019 10:19:25 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Srinivas Kandagatla , Jorge Ramirez Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 5/6] rpmsg: glink: Don't send pending rx_done during remove Date: Wed, 18 Sep 2019 10:19:15 -0700 Message-Id: <20190918171916.4039-6-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190918171916.4039-1-bjorn.andersson@linaro.org> References: <20190918171916.4039-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Attempting to transmit rx_done messages after the GLINK instance is being torn down will cause use after free and memory leaks. So cancel the intent_work and free up the pending intents. Fixes: 1d2ea36eead9 ("rpmsg: glink: Add rx done command") Cc: stable@vger.kernel.org Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_glink_native.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.18.0 diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 89e02baea2d0..0d7518a6ebf0 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -241,11 +241,23 @@ static void qcom_glink_channel_release(struct kref *ref) { struct glink_channel *channel = container_of(ref, struct glink_channel, refcount); + struct glink_core_rx_intent *intent; struct glink_core_rx_intent *tmp; unsigned long flags; int iid; + /* cancel pending rx_done work */ + cancel_work_sync(&channel->intent_work); + spin_lock_irqsave(&channel->intent_lock, flags); + /* Free all non-reuse intents pending rx_done work */ + list_for_each_entry_safe(intent, tmp, &channel->done_intents, node) { + if (!intent->reuse) { + kfree(intent->data); + kfree(intent); + } + } + idr_for_each_entry(&channel->liids, tmp, iid) { kfree(tmp->data); kfree(tmp); From patchwork Wed Sep 18 17:19:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 173989 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2732007ill; Wed, 18 Sep 2019 10:19:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtzMIT7Q8Mb4WJSA+7xmwVJOB8OQDKjfbAd/lS4DEJ2ip8VSGlDiuu9Uv8En+Mv03amyhN X-Received: by 2002:a05:6402:78b:: with SMTP id d11mr9618524edy.14.1568827175373; Wed, 18 Sep 2019 10:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568827175; cv=none; d=google.com; s=arc-20160816; b=A+Rvk8wvXivOFDi7Npd3RSFfimqKzh5/gtWyKRIp6fgE4kG45UMbIqNddwelXYCas8 TIQpdGXXPyNDkMxg9jIL7JL34HUdvnrocH1WbZOK/SXiuLZ2O4rFs55Kfcxzx5LIPj+M WYoMlzSP5SUQjxTYqiaDterGahvvC87EN037z+rpvVgjSnSiwO4LsHn73IXQZsMuB17q 7Ptemi6gajKBPC+qKYGm3bxhTo1P+WHGeU+o94U3IUpVsK88IORO/5ozHZ28Dpkcztla QC6QScOp4UB5d6bF7JyJSHe2Nb76oE4OEwM15jaSuQZMsATVn/7BkCcfs/dCk7l4Ec2T Cddg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=o8jBbFMTRVOLRjVfPalAAvaLLhvjkkI5HoxGIVyvU8o=; b=fdGKs1BkBgFb/UrbFMpy/S2AhWAs8PnfV1v2fBi9SXxVFTz0XG5iN778LH2kzIkCWd 7nnoZqmAtYy4Ddpx3gyYWyMxKkFhjL+mkhbBNPH27c04AgOicCCM7pW/zy24E2PScVRC N10TZzvp23Rbiitq0NKSP0pfkoVPrEwa/PPdYj4Ip70o+pesLKrliAHJAyw6ExeSbnIU HpwUayvQd5qUPhUI0DOQ5bAUz3ljUyU1u3VERJLTbsA/Gll/XVKnnz4HBgtejD/1knV2 pMFvEfM6zhuNHG//fYdrllccK4+4PLpvAtoy8fbjX0FhuSUyGCiRf3MidCMxcGt9v3fn d0Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S31B2pEs; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 r18si1604702ejr.189.2019.09.18.10.19.35; Wed, 18 Sep 2019 10:19:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=S31B2pEs; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1732151AbfIRRTb (ORCPT + 15 others); Wed, 18 Sep 2019 13:19:31 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38887 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732140AbfIRRT2 (ORCPT ); Wed, 18 Sep 2019 13:19:28 -0400 Received: by mail-pf1-f193.google.com with SMTP id h195so418202pfe.5 for ; Wed, 18 Sep 2019 10:19:28 -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:in-reply-to:references; bh=o8jBbFMTRVOLRjVfPalAAvaLLhvjkkI5HoxGIVyvU8o=; b=S31B2pEsbk+z279WHVu2T3GrmYwNDVVVEi/rj5HIvyV6nVgECY/7RfHJ/xSGEt3k8s xShPMHY9cudQDZP2dH2wQvi5BLCnKKfojyVvVTmE40etR2gvyyljlHoYoi6uumzoghtX w9Z9vYHDU4Nr8o77x/MECD8F0zYjEGM0wGFN0W6SV4mPq4kePFnte+jMuBjO+V9Mk2y0 PAcA8IRjRYXTcc9rvtEv5ImAlwMDeEupI6jzInysqLqlG72aANz/bomMqQVVysMA8gZM P5q4KvZmbHFyFK1W4gXjZrIhbNXctmumsmzN1F3DphKi2qR0jlIHMwLf4SO12NlkfTlY 7LCA== 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=o8jBbFMTRVOLRjVfPalAAvaLLhvjkkI5HoxGIVyvU8o=; b=DVLGqXJZJa4Ba26cXvcje4OeCqaZBtcz4GmGUOt4ktl4o4W3Ph725CDftmMyqpYSsW N3l+/RfHRxkYsgdclThBS2zf/wt/j/UBNCqnYLtZsbegu45GOwNoiO++NQ/gpr08qGiP RIljNYMAAKZynO2oy9Zs9WpH5aPnhE+3lW7CpqWuV6Lr5rv+zZauTKaA+R0HMbKWzT8G 7zxwCXy0D6YmXoRfdmdelZUGj7l1XWNcCoxtF8KAEqIlz9xurnbQf4lDqVyOXfDMnbih QRKzWkLMoXljOz4yIcKZxynRndkZK/a3uqIaJLmY6GQhhwdb0DzPrfTscH1UF8V0OPEB KrUw== X-Gm-Message-State: APjAAAVE9YuUBRFBIc8WJXek1fCvCRYBOthfNremLcBsZ0lPvEonMihJ bfYotOz9biCStzs4EfQCzrmC5A== X-Received: by 2002:a63:34cb:: with SMTP id b194mr4926065pga.446.1568827167913; Wed, 18 Sep 2019 10:19:27 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id y4sm2614981pjn.19.2019.09.18.10.19.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Sep 2019 10:19:27 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Srinivas Kandagatla , Jorge Ramirez Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 6/6] rpmsg: glink: Free pending deferred work on remove Date: Wed, 18 Sep 2019 10:19:16 -0700 Message-Id: <20190918171916.4039-7-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190918171916.4039-1-bjorn.andersson@linaro.org> References: <20190918171916.4039-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org By just cancelling the deferred rx worker during GLINK instance teardown any pending deferred commands are leaked, so free them. Fixes: b4f8e52b89f6 ("rpmsg: Introduce Qualcomm RPM glink driver") Cc: stable@vger.kernel.org Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_glink_native.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 2.18.0 diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 0d7518a6ebf0..5920432e697a 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1562,6 +1562,18 @@ static void qcom_glink_work(struct work_struct *work) } } +static void qcom_glink_cancel_rx_work(struct qcom_glink *glink) +{ + struct glink_defer_cmd *dcmd; + struct glink_defer_cmd *tmp; + + /* cancel any pending deferred rx_work */ + cancel_work_sync(&glink->rx_work); + + list_for_each_entry_safe(dcmd, tmp, &glink->rx_queue, node) + kfree(dcmd); +} + struct qcom_glink *qcom_glink_native_probe(struct device *dev, unsigned long features, struct qcom_glink_pipe *rx, @@ -1640,7 +1652,7 @@ void qcom_glink_native_remove(struct qcom_glink *glink) unsigned long flags; disable_irq(glink->irq); - cancel_work_sync(&glink->rx_work); + qcom_glink_cancel_rx_work(glink); ret = device_for_each_child(glink->dev, NULL, qcom_glink_remove_device); if (ret)