Re: [PATCH] Proper initialization of rc in drivers/ide/ide-probe.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 ( rakib.mullick@xxxxxxxxx)
> 
> --- 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 majordomo@xxxxxxxxxxxxxxx
> 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux