* [PATCH 1/1] MIPS: APRP: Fix an issue when device_create() fails.
@ 2014-06-19 20:30 Sebastien Bourdelin
2014-06-20 17:32 ` Deng-Cheng Zhu
0 siblings, 1 reply; 3+ messages in thread
From: Sebastien Bourdelin @ 2014-06-19 20:30 UTC (permalink / raw)
To: linux-mips, Ralf Baechle, Steven J. Hill, Deng-Cheng Zhu,
John Crispin, Qais Yousef
Cc: linux-kernel, Jerome Oufella, Sebastien Bourdelin
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] MIPS: APRP: Fix an issue when device_create() fails.
2014-06-19 20:30 [PATCH 1/1] MIPS: APRP: Fix an issue when device_create() fails Sebastien Bourdelin
@ 2014-06-20 17:32 ` Deng-Cheng Zhu
2014-06-20 19:15 ` Sebastien Bourdelin
0 siblings, 1 reply; 3+ messages in thread
From: Deng-Cheng Zhu @ 2014-06-20 17:32 UTC (permalink / raw)
To: Sebastien Bourdelin, linux-mips, Ralf Baechle, Steven J. Hill,
John Crispin, Qais Yousef
Cc: linux-kernel, Jerome Oufella
On 06/19/2014 01:30 PM, Sebastien Bourdelin wrote:
> 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--)
--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--)
Same here.
> + device_destroy(mt_class, MKDEV(major, i));
> +
> err = PTR_ERR(dev);
> goto out_chrdev;
> }
Deng-Cheng
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] MIPS: APRP: Fix an issue when device_create() fails.
2014-06-20 17:32 ` Deng-Cheng Zhu
@ 2014-06-20 19:15 ` Sebastien Bourdelin
0 siblings, 0 replies; 3+ messages in thread
From: Sebastien Bourdelin @ 2014-06-20 19:15 UTC (permalink / raw)
To: Deng-Cheng Zhu, linux-mips, Ralf Baechle, Steven J. Hill,
John Crispin, Qais Yousef
Cc: linux-kernel, Jerome Oufella
Hi,
correct me if i'm wrong, but if we pre-decrement, it will decrement
before evaluate and the channel 0 will never be destroy.
So the while condition must change too accordingly.
In any case inside the while loop, "i" will be "i - 1" so we destroy the
previously device.
I think it's correct like this.
On 06/20/2014 01:32 PM, Deng-Cheng Zhu wrote:
> On 06/19/2014 01:30 PM, Sebastien Bourdelin wrote:
>> 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--)
> --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--)
> Same here.
>
>> + device_destroy(mt_class, MKDEV(major, i));
>> +
>> err = PTR_ERR(dev);
>> goto out_chrdev;
>> }
>
>
> Deng-Cheng
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-06-20 19:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-19 20:30 [PATCH 1/1] MIPS: APRP: Fix an issue when device_create() fails Sebastien Bourdelin
2014-06-20 17:32 ` Deng-Cheng Zhu
2014-06-20 19:15 ` Sebastien Bourdelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).