linux-mips
[Top] [All Lists]

[PATCH 1/1] MIPS: APRP: Fix an issue when device_create() fails.

To: linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>, "Steven J. Hill" <Steven.Hill@imgtec.com>, Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>, John Crispin <blogic@openwrt.org>, Qais Yousef <Qais.Yousef@imgtec.com>
Subject: [PATCH 1/1] MIPS: APRP: Fix an issue when device_create() fails.
From: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
Date: Thu, 19 Jun 2014 16:30:23 -0400
Cc: linux-kernel@vger.kernel.org, Jerome Oufella <jerome.oufella@savoirfairelinux.com>, Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
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>
---
 arch/mips/kernel/rtlx-cmp.c | 3 +++
 arch/mips/kernel/rtlx-mt.c  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/arch/mips/kernel/rtlx-cmp.c b/arch/mips/kernel/rtlx-cmp.c
index 758fb3c..d26dcc4 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 5a66b97..cb95470 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;
                }
-- 
1.8.3.4


<Prev in Thread] Current Thread [Next in Thread>