Commit 560181d
nvmem: core: fix cleanup after dev_set_name()
If dev_set_name() fails, we leak nvmem->wp_gpio as the cleanup does not
put this. While a minimal fix for this would be to add the gpiod_put()
call, we can do better if we split device_register(), and use the
tested nvmem_release() cleanup code by initialising the device early,
and putting the device.
This results in a slightly larger fix, but results in clear code.
Note: this patch depends on "nvmem: core: initialise nvmem->id early"
and "nvmem: core: remove nvmem_config wp_gpio".
Fixes: 5544e90 ("nvmem: core: add error handling for dev_set_name")
Cc: [email protected]
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
[Srini: Fixed subject line and error code handing with wp_gpio while applying.]
Signed-off-by: Srinivas Kandagatla <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent 569653f commit 560181d
1 file changed
+10
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
772 | 772 | | |
773 | 773 | | |
774 | 774 | | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
775 | 781 | | |
776 | 782 | | |
777 | 783 | | |
778 | 784 | | |
779 | | - | |
780 | 785 | | |
781 | | - | |
782 | | - | |
| 786 | + | |
783 | 787 | | |
784 | 788 | | |
785 | 789 | | |
| |||
791 | 795 | | |
792 | 796 | | |
793 | 797 | | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | 798 | | |
798 | 799 | | |
799 | 800 | | |
| |||
821 | 822 | | |
822 | 823 | | |
823 | 824 | | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
| 825 | + | |
| 826 | + | |
829 | 827 | | |
830 | 828 | | |
831 | 829 | | |
| |||
836 | 834 | | |
837 | 835 | | |
838 | 836 | | |
839 | | - | |
| 837 | + | |
840 | 838 | | |
841 | 839 | | |
842 | 840 | | |
| |||
0 commit comments