Re: [PATCH] edd: fix error paths in module_init

Previous thread: [PATCH] byteorder: add put/get_{endian} helpers by Harvey Harrison on Thursday, May 29, 2008 - 10:54 am. (1 message)

Next thread: [PATCH] genirq: Expose default irq affinity mask (take 3) by Max Krasnyansky on Thursday, May 29, 2008 - 11:02 am. (4 messages)
From: devzero
Date: Thursday, May 29, 2008 - 10:56 am

Hi Akinobu, 

it looks that your patch is fixing this one :

https://bugzilla.novell.com/show_bug.cgi?id=394571
https://bugzilla.novell.com/attachment.cgi?id=218198

i didn`t yet try, but maybe you are able to take a look and confirm ?

if this is correct - how did you manage looking two days into the future ? ;)

roland



List:       linux-kernel
Subject:    Re: [PATCH] edd: fix error paths in module_init
From:       Akinobu Mita <akinobu.mita () gmail ! com>
Date:       2008-05-24 8:13:09
Message-ID: 20080524081308.GA30441 () APFDCB5C
[Download message RAW]




OK. This is update patch.

From: Akinobu Mita <akinobu.mita@gmail.com>
Subject: edd: fix error paths in module_init 

If kzalloc() or edd_device_register() failed in module_init, it returns
error without cleanup the devices already registered.

Rather than fixing it to back completely out (unregister everything that had
successfully registered until now) and return error, This patch makes it
have succeeded. Because having even the first device be reported, even if
the others couldn't be, is useful.

Also this patch fixes return value of module_init. module_init should not
return positive value.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Matt Domsch <Matt_Domsch@dell.com>
---
 drivers/firmware/edd.c |   20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

Index: 2.6-git/drivers/firmware/edd.c
===================================================================
--- 2.6-git.orig/drivers/firmware/edd.c
+++ 2.6-git/drivers/firmware/edd.c
@@ -718,8 +718,8 @@ edd_device_register(struct edd_device *e
 {
 	int error;
 
-	if (!edev)
-		return 1;
+	if (WARN_ON(!edev))
+		return -EINVAL;
 	edd_dev_set_info(edev, i);
 	edev->kobj.kset = edd_kset;
 	error = kobject_init_and_add(&edev->kobj, &edd_ktype, NULL,
@@ -744,8 +744,8 @@ static inline int edd_num_devices(void)
 static int __init
 edd_init(void)
 {
-	unsigned int i;
-	int rc=0;
+	int i;
+	int rc;
 ...
From: Akinobu Mita
Date: Friday, May 30, 2008 - 7:02 am

yep, the patch must fix this bug.
--

Previous thread: [PATCH] byteorder: add put/get_{endian} helpers by Harvey Harrison on Thursday, May 29, 2008 - 10:54 am. (1 message)

Next thread: [PATCH] genirq: Expose default irq affinity mask (take 3) by Max Krasnyansky on Thursday, May 29, 2008 - 11:02 am. (4 messages)