Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Borislav Petkov <petkovbb <at> googlemail.com>
Subject: Re: [PATCH] Proper initialization of rc in drivers/ide/ide-probe.c
Newsgroups: gmane.linux.ide
Date: Saturday 26th July 2008 08:45:31 UTC (over 9 years ago)
On Fri, Jul 25, 2008 at 11:54:17PM +0600, Rakib Mullick wrote:
> Hello to all , In existing code, rc might remain uninitialized.
Hi,

are you sure? device_create_file() does return a proper value at all times:
either a 0 or the result from calling sysfs_create_file(), and, if you
follow
the last's call chain into the sysfs-internals you can easily see that
those
functions also return proper value at all times. What is more, it is
guaranteed
that the loop will execute since ide_port_attrs is statically initialized
and has 2 elements... so no need for initializing the rc-variable - it gets
overwritten in any case.

However, i'm sure you can find some other places in the kernel where the
return
value is not set appropriately, leading to really nasty bugs :(.

> This patch initializes rc properly.
> 
> Signed-off-by: Md.Rakib Hassan Mullick ( [email protected])
> 
> --- drivers/ide/ide-probe.c.orig	2008-07-25 23:33:22.000000000 +0600
> +++ drivers/ide/ide-probe.c	2008-07-25 23:35:00.000000000 +0600
> @@ -1437,7 +1437,7 @@ static struct device_attribute *ide_port
> 
>  static int ide_sysfs_register_port(ide_hwif_t *hwif)
>  {
> -	int i, rc;
> +	int i, rc = 0;
> 
>  	for (i = 0; ide_port_attrs[i]; i++) {
>  		rc = device_create_file(hwif->portdev, ide_port_attrs[i]);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Regards/Gruß,
    Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
 
CD: 3ms