devm_kfree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is it reasonable to use devm_kfree in a probe function that fails or a remove function that succeeds?

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);
 out_release:
- devm_release_mem_region(&pdev->dev, res->start, resource_size(res));

        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);

	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 kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux