From: Sebastien Bourdelin Date: Thu, 19 Jun 2014 20:30:23 +0000 (-0400) Subject: MIPS: APRP: Fix an issue when device_create() fails. X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=0435b13ee3732c1dda5312025f49073d01d8d15d;p=linux-beck.git MIPS: APRP: Fix an issue when device_create() fails. If a call to device_create() fails for a channel during the initialize loop, we need to clean the devices entries already created before leaving. Signed-off-by: Sebastien Bourdelin Cc: linux-mips@linux-mips.org Cc: Steven J. Hill Cc: Deng-Cheng Zhu Cc: John Crispin Cc: Qais Yousef Cc: linux-kernel@vger.kernel.org Cc: Jerome Oufella Patchwork: https://patchwork.linux-mips.org/patch/7111/ Signed-off-by: Ralf Baechle --- diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c index 758fb3cd2326..d26dcc4b46e7 100644 --- a/arch/mips/kernel/rtlx-cmp.c +++ b/arch/mips/kernel/rtlx-cmp.c @@ -77,6 +77,9 @@ int __init rtlx_module_init(void) dev = device_create(mt_class, NULL, MKDEV(major, i), NULL, "%s%d", RTLX_MODULE_NAME, i); if (IS_ERR(dev)) { + while (i--) + device_destroy(mt_class, MKDEV(major, i)); + err = PTR_ERR(dev); goto out_chrdev; } diff --git a/arch/mips/kernel/rtlx-mt.c b/arch/mips/kernel/rtlx-mt.c index 5a66b975989e..cb95470e2e69 100644 --- a/arch/mips/kernel/rtlx-mt.c +++ b/arch/mips/kernel/rtlx-mt.c @@ -103,6 +103,9 @@ int __init rtlx_module_init(void) dev = device_create(mt_class, NULL, MKDEV(major, i), NULL, "%s%d", RTLX_MODULE_NAME, i); if (IS_ERR(dev)) { + while (i--) + device_destroy(mt_class, MKDEV(major, i)); + err = PTR_ERR(dev); goto out_chrdev; }