提交 942bfb3e 编写于 作者: W Wei Yongjun 提交者: Linus Torvalds

drivers/rtc/rtc-test.c: avoid calling platform_device_put() twice

In case of error, test_init() needs to call platform_device_del() instead
of platform_device_unregister().  Otherwise, we may call
platform_device_put() twice.

dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

[akpm@linux-foundation.org: improve label naming]
Signed-off-by: NWei Yongjun <yongjun_wei@trendmicro.com.cn>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 0d7ecb83
...@@ -152,24 +152,24 @@ static int __init test_init(void) ...@@ -152,24 +152,24 @@ static int __init test_init(void)
if ((test1 = platform_device_alloc("rtc-test", 1)) == NULL) { if ((test1 = platform_device_alloc("rtc-test", 1)) == NULL) {
err = -ENOMEM; err = -ENOMEM;
goto exit_free_test0; goto exit_put_test0;
} }
if ((err = platform_device_add(test0))) if ((err = platform_device_add(test0)))
goto exit_free_test1; goto exit_put_test1;
if ((err = platform_device_add(test1))) if ((err = platform_device_add(test1)))
goto exit_device_unregister; goto exit_del_test0;
return 0; return 0;
exit_device_unregister: exit_del_test0:
platform_device_unregister(test0); platform_device_del(test0);
exit_free_test1: exit_put_test1:
platform_device_put(test1); platform_device_put(test1);
exit_free_test0: exit_put_test0:
platform_device_put(test0); platform_device_put(test0);
exit_driver_unregister: exit_driver_unregister:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册