Skip to content

Commit 488e7b2

Browse files
jhovoldgregkh
authored andcommitted
powerpc/ibmebus: Fix further device reference leaks
commit 815a7141c4d1b11610dccb7fcbb38633759824f2 upstream. Make sure to drop any reference taken by bus_find_device() when creating devices during init and driver registration. Fixes: 55347cc ("[POWERPC] ibmebus: Add device creation and bus probing based on of_device") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4d1b508 commit 488e7b2

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

arch/powerpc/kernel/ibmebus.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ static int ibmebus_create_device(struct device_node *dn)
180180
static int ibmebus_create_devices(const struct of_device_id *matches)
181181
{
182182
struct device_node *root, *child;
183+
struct device *dev;
183184
int ret = 0;
184185

185186
root = of_find_node_by_path("/");
@@ -188,9 +189,12 @@ static int ibmebus_create_devices(const struct of_device_id *matches)
188189
if (!of_match_node(matches, child))
189190
continue;
190191

191-
if (bus_find_device(&ibmebus_bus_type, NULL, child,
192-
ibmebus_match_node))
192+
dev = bus_find_device(&ibmebus_bus_type, NULL, child,
193+
ibmebus_match_node);
194+
if (dev) {
195+
put_device(dev);
193196
continue;
197+
}
194198

195199
ret = ibmebus_create_device(child);
196200
if (ret) {

0 commit comments

Comments
 (0)