ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: Yuan Can <yuancan@huawei.com>
To: <wens@csie.org>, <jernej.skrabec@gmail.com>,
	<samuel@sholland.org>, <gregkh@linuxfoundation.org>,
	<christophe.jaillet@wanadoo.fr>, <tglx@linutronix.de>,
	<arnd@arndb.de>, <mripard@kernel.org>, <broonie@kernel.org>,
	<olof@lixom.net>, <linux-arm-kernel@lists.infradead.org>,
	<linux-sunxi@lists.linux.dev>
Cc: <yuancan@huawei.com>
Subject: [PATCH] bus: sunxi-rsb: Fix error handling in sunxi_rsb_init()
Date: Wed, 23 Nov 2022 09:42:00 +0000	[thread overview]
Message-ID: <20221123094200.12036-1-yuancan@huawei.com> (raw)

The sunxi_rsb_init() returns the platform_driver_register() directly
without checking its return value, if platform_driver_register() failed,
the sunxi_rsb_bus is not unregistered.
Fix by unregister sunxi_rsb_bus when platform_driver_register() failed.

Fixes: d787dcdb9c8f ("bus: sunxi-rsb: Add driver for Allwinner Reduced Serial Bus")
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
 drivers/bus/sunxi-rsb.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c
index 4cd2e127946e..87b10011667c 100644
--- a/drivers/bus/sunxi-rsb.c
+++ b/drivers/bus/sunxi-rsb.c
@@ -853,7 +853,13 @@ static int __init sunxi_rsb_init(void)
 		return ret;
 	}
 
-	return platform_driver_register(&sunxi_rsb_driver);
+	ret = platform_driver_register(&sunxi_rsb_driver);
+	if (ret) {
+		bus_unregister(&sunxi_rsb_bus);
+		return ret;
+	}
+
+	return 0;
 }
 module_init(sunxi_rsb_init);
 
-- 
2.17.1


             reply	other threads:[~2022-11-23  9:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  9:42 Yuan Can [this message]
2022-12-05 21:13 ` [PATCH] bus: sunxi-rsb: Fix error handling in sunxi_rsb_init() Jernej Škrabec
2023-01-08 20:35 ` Jernej Škrabec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221123094200.12036-1-yuancan@huawei.com \
    --to=yuancan@huawei.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mripard@kernel.org \
    --cc=olof@lixom.net \
    --cc=samuel@sholland.org \
    --cc=tglx@linutronix.de \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox