From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AC048494 for ; Thu, 5 Jan 2023 13:04:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C66B7C433D2; Thu, 5 Jan 2023 13:04:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672923855; bh=w+kbopR9lEp1/FZPvOxTknkJByTEBYiAwaZASAxkz10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lg+IUtRb6Gv0OUw1JCjVRYRbphuC+geoGJcMB++rdydCMjPTIUfJJEqHT5CoR91dI NAcuTBnXB8ivUdCmB1083DnectPxJZj6rLlcWwOV6n9MxK/kcBTeM45ORKs74gUeZU hgztjmBcGOZ4M1fJ6VGZSt1VKlvo4IunKMm9vQHE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yang Yingliang , Sebastian Reichel , Sasha Levin Subject: [PATCH 4.9 154/251] HSI: omap_ssi_core: fix possible memory leak in ssi_probe() Date: Thu, 5 Jan 2023 13:54:51 +0100 Message-Id: <20230105125341.872474132@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105125334.727282894@linuxfoundation.org> References: <20230105125334.727282894@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Yang Yingliang [ Upstream commit 1aff514e1d2bd47854dbbdf867970b9d463d4c57 ] If ssi_add_controller() returns error, it should call hsi_put_controller() to give up the reference that was set in hsi_alloc_controller(), so that it can call hsi_controller_release() to free controller and ports that allocated in hsi_alloc_controller(). Fixes: b209e047bc74 ("HSI: Introduce OMAP SSI driver") Signed-off-by: Yang Yingliang Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/hsi/controllers/omap_ssi_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hsi/controllers/omap_ssi_core.c b/drivers/hsi/controllers/omap_ssi_core.c index db9328c05492..9e82f9f8f0a3 100644 --- a/drivers/hsi/controllers/omap_ssi_core.c +++ b/drivers/hsi/controllers/omap_ssi_core.c @@ -540,8 +540,10 @@ static int ssi_probe(struct platform_device *pd) platform_set_drvdata(pd, ssi); err = ssi_add_controller(ssi, pd); - if (err < 0) + if (err < 0) { + hsi_put_controller(ssi); goto out1; + } pm_runtime_enable(&pd->dev); -- 2.35.1