Messages in this thread | | | Date | Tue, 27 Dec 2011 11:48:18 +0900 | Subject | Re: devm_kfree | From | Adam Jiang <> |
| |
2011/12/26 Julia Lawall <julia.lawall@lip6.fr>: > Is it reasonable to use devm_kfree in a probe function that fails or a > remove function that succeeds?
I cannot catch your question. If the memory is allocated by devm_kzalloc(), it is not necessary to release with devm_kfree() at all. It would be release once the driver was detached or destroyed.
> > Examples from drivers/watchdog/shwdt.c: > > sh_wdt_probe: > > ... > out_unreg: > unregister_reboot_notifier(&sh_wdt_notifier); > out_unmap: > - devm_iounmap(&pdev->dev, wdt->base); > out_err: > - devm_kfree(&pdev->dev, wdt);
It is necessary?
> out_release: > - devm_release_mem_region(&pdev->dev, res->start, resource_size(res));
It is necessary?
> > return rc; > } > > > sh_wdt_remove: > > ... > unregister_reboot_notifier(&sh_wdt_notifier); > devm_release_mem_region(&pdev->dev, res->start, resource_size(res)); > devm_iounmap(&pdev->dev, wdt->base); > devm_kfree(&pdev->dev, wdt);
These lines should be deleted if the driver has detached.
> > return 0; > } > > > On the other hand, perhaps devm_kfree is needed in probe function that > succeeds, eg in drivers/input/keyboard/samsung-keypad.c: > > if (pdev->dev.of_node) { > devm_kfree(&pdev->dev, (void *)pdata->keymap_data->keymap); > devm_kfree(&pdev->dev, (void *)pdata->keymap_data); > devm_kfree(&pdev->dev, (void *)pdata); > } > return 0; > > julia > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |