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 85ED28494 for ; Thu, 5 Jan 2023 13:04:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDB80C433D2; Thu, 5 Jan 2023 13:04:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672923864; bh=z1NuVHnKQGJSyQXe68j7nZiY6vbA+EReBWlueKFsAs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o/pDd+PtTTPxR8nyNPqlw1SIq6GcL2bY0GCRoJXf3v3WGGPw3YRm7s3fRLPHT7q7d qefhXRJodDrW9RanoY21RoVb+/7vPcfojOy8CyG7EtR5W/iUtOM02gABr37PH5K2CD iiXrvndOv71UnWmKdydYBTQDOppQapnoxdPbMgqY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuan Can , Sebastian Reichel , Sasha Levin Subject: [PATCH 4.9 156/251] HSI: omap_ssi_core: Fix error handling in ssi_init() Date: Thu, 5 Jan 2023 13:54:53 +0100 Message-Id: <20230105125341.969251959@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: Yuan Can [ Upstream commit 3ffa9f713c39a213a08d9ff13ab983a8aa5d8b5d ] The ssi_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, the ssi_pdriver is not unregistered. Fix by unregister ssi_pdriver when the last platform_driver_register() failed. Fixes: 0fae198988b8 ("HSI: omap_ssi: built omap_ssi and omap_ssi_port into one module") Signed-off-by: Yuan Can Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/hsi/controllers/omap_ssi_core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/hsi/controllers/omap_ssi_core.c b/drivers/hsi/controllers/omap_ssi_core.c index 9e82f9f8f0a3..c885c3bc2e85 100644 --- a/drivers/hsi/controllers/omap_ssi_core.c +++ b/drivers/hsi/controllers/omap_ssi_core.c @@ -669,7 +669,13 @@ static int __init ssi_init(void) { if (ret) return ret; - return platform_driver_register(&ssi_port_pdriver); + ret = platform_driver_register(&ssi_port_pdriver); + if (ret) { + platform_driver_unregister(&ssi_pdriver); + return ret; + } + + return 0; } module_init(ssi_init); -- 2.35.1