All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Thumshirn <jth@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, "Rodríguez Barbarin,
	José Javier" <JoseJavier.Rodriguez@duagon.com>,
	"Jorge Sanjuan Garcia" <jorge.sanjuangarcia@duagon.com>,
	"Javier Rodriguez" <josejavier.rodriguez@duagon.com>,
	"Johannes Thumshirn" <jth@kernel.org>
Subject: [PATCH 1/1] mcb: Do not add the mcb_bus_type to the mcb_bus itself
Date: Mon, 10 Jul 2023 16:57:52 +0200	[thread overview]
Message-ID: <20230710145752.14285-2-jth@kernel.org> (raw)
In-Reply-To: <20230710145752.14285-1-jth@kernel.org>

From: Rodríguez Barbarin, José Javier <JoseJavier.Rodriguez@duagon.com>

When allocating a new mcb_bus the bus_type is added to the mcb_bus
itself, causing an issue when calling mcb_bus_add_devices().
This function is not only called for each mcb_device under the
mcb_bus but for the bus itself.

This causes a crash when freeing the ida resources as the bus numbering
gets corrupted due to a wrong cast of structs mcb_bus and mcb_device.

Make the release of the mcb devices and their mcb bus explicit.

Co-developed-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
Signed-off-by: Javier Rodriguez <josejavier.rodriguez@duagon.com>
Signed-off-by: Johannes Thumshirn <jth@kernel.org>
---
 drivers/mcb/mcb-core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 978fdfc19a06..d4535b8aea1d 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -251,6 +251,12 @@ int mcb_device_register(struct mcb_bus *bus, struct mcb_device *dev)
 }
 EXPORT_SYMBOL_NS_GPL(mcb_device_register, MCB);
 
+
+static void mcb_bus_unregister(struct mcb_bus *bus)
+{
+	device_unregister(&bus->dev);
+}
+
 static void mcb_free_bus(struct device *dev)
 {
 	struct mcb_bus *bus = to_mcb_bus(dev);
@@ -286,7 +292,6 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
 
 	device_initialize(&bus->dev);
 	bus->dev.parent = carrier;
-	bus->dev.bus = &mcb_bus_type;
 	bus->dev.type = &mcb_carrier_device_type;
 	bus->dev.release = &mcb_free_bus;
 
@@ -322,6 +327,7 @@ static void mcb_devices_unregister(struct mcb_bus *bus)
 void mcb_release_bus(struct mcb_bus *bus)
 {
 	mcb_devices_unregister(bus);
+	mcb_bus_unregister(bus);
 }
 EXPORT_SYMBOL_NS_GPL(mcb_release_bus, MCB);
 
-- 
2.40.1


  reply	other threads:[~2023-07-10 14:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-10 14:57 [PATCH 0/1] mcb patchses for v6.6 Johannes Thumshirn
2023-07-10 14:57 ` Johannes Thumshirn [this message]
2023-07-10 15:05   ` [PATCH 1/1] mcb: Do not add the mcb_bus_type to the mcb_bus itself Greg Kroah-Hartman
2023-08-18 11:02     ` [PATCH v2 0/1] mcb: Fix crash mcb-core module is removed Rodríguez Barbarin, José Javier
2023-08-18 11:03       ` [PATCH v2 1/1] mcb: create dedicated bus_type for mcb_bus and mcb_device Rodríguez Barbarin, José Javier
2023-08-19  9:56         ` gregkh
2023-08-23  8:07           ` Sanjuán García, Jorge
  -- strict thread matches above, loose matches on Subject: below --
2023-06-16 11:37 [PATCH 0/1] mcb: Fix crash mcb-core module is removed Rodríguez Barbarin, José Javier
2023-06-16 11:38 ` [PATCH 1/1] mcb: Do not add the mcb_bus_type to the mcb_bus itself Rodríguez Barbarin, José Javier

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=20230710145752.14285-2-jth@kernel.org \
    --to=jth@kernel.org \
    --cc=JoseJavier.Rodriguez@duagon.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jorge.sanjuangarcia@duagon.com \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.