@@ -180,6 +180,7 @@ static int ibmebus_create_device(struct device_node *dn)
180180static 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 ) {
@@ -262,15 +266,18 @@ static ssize_t ibmebus_store_probe(struct bus_type *bus,
262266 const char * buf , size_t count )
263267{
264268 struct device_node * dn = NULL ;
269+ struct device * dev ;
265270 char * path ;
266271 ssize_t rc = 0 ;
267272
268273 path = ibmebus_chomp (buf , count );
269274 if (!path )
270275 return - ENOMEM ;
271276
272- if (bus_find_device (& ibmebus_bus_type , NULL , path ,
273- ibmebus_match_path )) {
277+ dev = bus_find_device (& ibmebus_bus_type , NULL , path ,
278+ ibmebus_match_path );
279+ if (dev ) {
280+ put_device (dev );
274281 printk (KERN_WARNING "%s: %s has already been probed\n" ,
275282 __func__ , path );
276283 rc = - EEXIST ;
@@ -307,6 +314,7 @@ static ssize_t ibmebus_store_remove(struct bus_type *bus,
307314 if ((dev = bus_find_device (& ibmebus_bus_type , NULL , path ,
308315 ibmebus_match_path ))) {
309316 of_device_unregister (to_platform_device (dev ));
317+ put_device (dev );
310318
311319 kfree (path );
312320 return count ;
0 commit comments