lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 27 Dec 2011 07:10:42 +0100 (CET) From: Julia Lawall <julia.lawall@...6.fr> To: Adam Jiang <jiang.adam@...il.com> cc: kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org Subject: Re: devm_kfree On Tue, 27 Dec 2011, Adam Jiang wrote: > 2011/12/26 Julia Lawall <julia.lawall@...6.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. Perhaps it is undesirable to keep it around until then, as in my last example below where the probe function seems to want to go with a different solution in some cases? I was also worried that one call could make some information required by another one unavailable. For example in the following case: drivers/dma/mpc512x_dma.c devm_free_irq(dev, mdma->irq, mdma); irq_dispose_mapping(mdma->irq); Is it OK to call irq_dispose_mapping and then let devm_free_irq be called implicitly afterwards? julia > >> >> 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@...r.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 kernel-janitors" in > the body of a message to majordomo@...r.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >
Powered by blists - more mailing lists