MIPS: APRP: Fix an issue when device_create() fails.
authorSebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
Thu, 19 Jun 2014 20:30:23 +0000 (16:30 -0400)
committerRalf Baechle <ralf@linux-mips.org>
Fri, 1 Aug 2014 15:30:35 +0000 (17:30 +0200)
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 <sebastien.bourdelin@savoirfairelinux.com>
Cc: linux-mips@linux-mips.org
Cc: Steven J. Hill <Steven.Hill@imgtec.com>
Cc: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Cc: John Crispin <blogic@openwrt.org>
Cc: Qais Yousef <Qais.Yousef@imgtec.com>
Cc: linux-kernel@vger.kernel.org
Cc: Jerome Oufella <jerome.oufella@savoirfairelinux.com>
Patchwork: https://patchwork.linux-mips.org/patch/7111/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/kernel/rtlx-cmp.c
arch/mips/kernel/rtlx-mt.c

index 758fb3cd2326c34dd119d86d1c3ee5c5d148ee29..d26dcc4b46e7414e79c866054cd0078cc68409ca 100644 (file)
@@ -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;
                }
index 5a66b975989e47917201ae6f304e6327aac58afd..cb95470e2e69e50bb6e89ef7e92fc3afc4b2d5a6 100644 (file)
@@ -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;
                }