hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/mmc/core/sdio_bus.c
....@@ -295,6 +295,12 @@
295295 if (!(func->card->quirks & MMC_QUIRK_NONSTD_SDIO))
296296 sdio_free_func_cis(func);
297297
298
+ /*
299
+ * We have now removed the link to the tuples in the
300
+ * card structure, so remove the reference.
301
+ */
302
+ put_device(&func->card->dev);
303
+
298304 kfree(func->info);
299305 kfree(func->tmpbuf);
300306 kfree(func);
....@@ -324,6 +330,12 @@
324330 func->card = card;
325331
326332 device_initialize(&func->dev);
333
+
334
+ /*
335
+ * We may link to tuples in the card structure,
336
+ * we need make sure we have a reference to it.
337
+ */
338
+ get_device(&func->card->dev);
327339
328340 func->dev.parent = &card->dev;
329341 func->dev.bus = &sdio_bus_type;
....@@ -378,10 +390,9 @@
378390 */
379391 void sdio_remove_func(struct sdio_func *func)
380392 {
381
- if (!sdio_func_present(func))
382
- return;
393
+ if (sdio_func_present(func))
394
+ device_del(&func->dev);
383395
384
- device_del(&func->dev);
385396 of_node_put(func->dev.of_node);
386397 put_device(&func->dev);
387398 }