]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
rpmsg: glink: Fix reuse intents memory leak issue
authorArun Kumar Neelakantam <aneela@codeaurora.org>
Fri, 4 Oct 2019 22:26:57 +0000 (15:26 -0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 29 Jan 2020 04:45:21 +0000 (23:45 -0500)
BugLink: https://bugs.launchpad.net/bugs/1859249
commit b85f6b601407347f5425c4c058d1b7871f5bf4f0 upstream.

Memory allocated for re-usable intents are not freed during channel
cleanup which causes memory leak in system.

Check and free all re-usable memory to avoid memory leak.

Fixes: 933b45da5d1d ("rpmsg: glink: Add support for TX intents")
Cc: stable@vger.kernel.org
Acked-By: Chris Lew <clew@codeaurora.org>
Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Reported-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/rpmsg/qcom_glink_native.c

index 40d76d2a5efff58339c0b823be3678591c99482e..0562a83b5f79d1dd4ab635e035d8160a9c967242 100644 (file)
@@ -243,10 +243,19 @@ 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 *tmp;
        unsigned long flags;
+       int iid;
 
        spin_lock_irqsave(&channel->intent_lock, flags);
+       idr_for_each_entry(&channel->liids, tmp, iid) {
+               kfree(tmp->data);
+               kfree(tmp);
+       }
        idr_destroy(&channel->liids);
+
+       idr_for_each_entry(&channel->riids, tmp, iid)
+               kfree(tmp);
        idr_destroy(&channel->riids);
        spin_unlock_irqrestore(&channel->intent_lock, flags);