Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2283910ybl; Thu, 19 Dec 2019 11:00:19 -0800 (PST) X-Google-Smtp-Source: APXvYqyeL9RWgGug1RK98UhKYOyW+/MdZsNOndd0hBu5VNWE5lkd/OcnUS7cLGMmSgd2BsnW79Ks X-Received: by 2002:a9d:7c91:: with SMTP id q17mr9876077otn.70.1576782019072; Thu, 19 Dec 2019 11:00:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576782019; cv=none; d=google.com; s=arc-20160816; b=vITcofEsmohnVQCAuKAoWll6c6G6u+Adgyls9EOu4SCPciUDdgWq6UKypOMuXjecTC qshYbmfPAU+G+bBvoUDlg6l2LBU1xKI4jC9o1bAAEJvJBck6FrgEdQOWBda+Ecz0yjUw Q9L1tn7fl/7OzsovD8WmkRDP+QtKymDQFkR+CxFqwG6HU7veSbkUypq3DFUhJEyobddW lKYT41iBLsqNThF4HCakziUAqCVu48DmA40auAFDj/wO93AIL9wb+nb2qKFpVc01f3bm 5+Qh4EEE6J4RqvBQ7LBtK2n5Bm2jZjsNlvwDdMI9KkM+EX52yO45cbGmRwsvgZIwofsi EvsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ucFRjXsi+CsMU6FT5MSv0/oRkQFVhKXjG2TI0sxxcUQ=; b=WclsMelXerzUKhED4IGqnqA2YZXHe21Y9W4QY7Z2lHrnvPSvKNqSWgQvwWc5m70mw4 tz2GR1aEW4VbWJlVMV0Y+HJAxnoWGOyvNsGptYYFAiVCeRweDvcCirpOa+SAm84fNg2V Y55h0AU0dgCHh3Y0U60hUfR6MkoP4A3vuUeWZa8yFMKNVSpeL/1WtQ3yHa5rkI5jUQKd S5a4vm5MhLBxUtJ03l57K+wy2jTMJAgx0L6GDbhZTgrdiWi0vhQd+9OjB0m0tiSPcqKW Bckq6Fs88h6KWNwMODVBr6OqOScCbXNxmMyekyELNS4QvH+/mRNYz18C8/VYX54akV+n JFPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Htmm0SMm; 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 m26si3706771otn.307.2019.12.19.11.00.07; Thu, 19 Dec 2019 11:00:19 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=Htmm0SMm; 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 S1730446AbfLSSyH (ORCPT + 99 others); Thu, 19 Dec 2019 13:54:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:49482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730113AbfLSSyH (ORCPT ); Thu, 19 Dec 2019 13:54:07 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B6BA222C2; Thu, 19 Dec 2019 18:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781646; bh=/RNUeUREqrykBAIP7/HzWlhfDvzGVU7SOlxeDFPZBec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Htmm0SMmCegSi5jiG/4Q1TZmjKIbGLTZEv5+lmGZ/YSYE+W7fRATJGEdtyZhM95wH 48WTOvB47fLbwGfBzUW/RqQbqaiNXJdLOY9KfMr1VVq9U6TjXX8tNAdGBC2Q8jnZJN KbnUc7xKygmR4r2ktLyLC+3MXDWY1mDJJlO5OVxk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Lew , Srinivas Kandagatla , Arun Kumar Neelakantam , Bjorn Andersson Subject: [PATCH 5.4 22/80] rpmsg: glink: Fix reuse intents memory leak issue Date: Thu, 19 Dec 2019 19:34:14 +0100 Message-Id: <20191219183101.706269733@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183031.278083125@linuxfoundation.org> References: <20191219183031.278083125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arun Kumar Neelakantam 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 Tested-by: Srinivas Kandagatla Signed-off-by: Arun Kumar Neelakantam Reported-by: Srinivas Kandagatla Signed-off-by: Bjorn Andersson Signed-off-by: Greg Kroah-Hartman --- drivers/rpmsg/qcom_glink_native.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -241,10 +241,19 @@ static void qcom_glink_channel_release(s { 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);