From patchwork Tue Jun 23 19:53:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 191555 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp2306620ile; Tue, 23 Jun 2020 13:23:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAzvvWxvV987vfFm2edrey29c5Da240Cx7xuFUSjMs7ML08bLnJfIWIWyMFN2wDtbSCk1s X-Received: by 2002:a50:fe94:: with SMTP id d20mr22869047edt.254.1592943820106; Tue, 23 Jun 2020 13:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592943820; cv=none; d=google.com; s=arc-20160816; b=eMRI1dbR/5QyhZNlh5SHpWmS1Kc0MD0C/eE/xg2JbGQCKPZEgZ5ZAphuKfiSnva758 NKlOtiAgsIQh2l9ZMvwA09BnC8AfrFvC5EUgugJh/W9RGV9s/lcT/35Fo/uG09ixERB2 CKwrBa318Cr5neFBXTfP45HJZufveb9iickF7bs94jrtxcTrcj+6gTpP6SBfLnlLbSS6 REUpyiDw0h7j9rj/zVIUaAbU2C6wdwGqCIqilPJKpIbPcxVvSc/FwSlt3mfFTjybjEyO ZmlivfZicuDXn8Q+zVZDJzIvWkP+qhFPIFvMf3A1GwM6eSY6EHIglv1mRsJgbMP1lnWB 73OA== 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=Hpp72omukEXCCnwvYhw8P9trzdgGvl7j6gT48IvlxME=; b=HrFXtn5d21sfEQxxwlqyB2TSjn+uqM1mFvUxDBqZLt35priXV6nYz/n7BwiLrFBfcl pbi/6jCVFc8a9vFSRsZYVDQJlq4oO6JInVt2zKSFt8ppXpC1JrBFYHtrMfLN2pZfhn6n YzZcf37qsAviZhTv84WT1PejtatROCKzKSUenTbjXLKQLT2PYurKiYxS6P84eGqehYVr 508hDUwKIbc3KmkLcVtXZxMWNRQXmsHs4Pp0pj2vXl30lanpilMMhn2AnyvbHPLAGqZf ShMx8e544oJtECC5vgBPiAkE5WXf7Zz2Ow8UW9bsjed6cumQDuxTMzCrLD2SpmYfyPwr MfzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="xX/JuHyz"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t25si11765618edq.407.2020.06.23.13.23.39; Tue, 23 Jun 2020 13:23:40 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="xX/JuHyz"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390041AbgFWUXi (ORCPT + 15 others); Tue, 23 Jun 2020 16:23:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:41812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389399AbgFWUXh (ORCPT ); Tue, 23 Jun 2020 16:23:37 -0400 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 8F7472070E; Tue, 23 Jun 2020 20:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592943817; bh=pBFSjGkku60qxWIrDHSWrcAFOrzcX0FpQ9HRqw4cDXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xX/JuHyzE0SJOsEfS416HJ9L2KFPlv8rIAiUtBtjfbR75i/2i4/fgFbFVHDsIEaPn bOWnYLH2PIVqMiPkzbDe6SpRfvH68KXz/49F+Tp46+LTom6drD3kniIiQA/tO+uHfJ MadSraoA5PTpMCa5PAYCErwYaeWZy4BXdywB2tUE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Kandagatla , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.4 032/314] misc: fastrpc: Fix an incomplete memory release in fastrpc_rpmsg_probe() Date: Tue, 23 Jun 2020 21:53:47 +0200 Message-Id: <20200623195340.354548339@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195338.770401005@linuxfoundation.org> References: <20200623195338.770401005@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Srinivas Kandagatla [ Upstream commit 0978de9fc7335c73934ab8fac189fb4cb3f23191 ] fastrpc_channel_ctx is not freed if misc_register() fails, this would lead to a memory leak. Fix this leak by adding kfree in misc_register() error path. Fixes: 278d56f970ae ("misc: fastrpc: Reference count channel context") Signed-off-by: Srinivas Kandagatla Reviewed-by: Bjorn Andersson Link: https://lore.kernel.org/r/20200511162722.2552-1-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/fastrpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 842f2210dc7e2..ee3291f7e6156 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1434,8 +1434,10 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) domains[domain_id]); data->miscdev.fops = &fastrpc_fops; err = misc_register(&data->miscdev); - if (err) + if (err) { + kfree(data); return err; + } kref_init(&data->refcount);