lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 18 Apr 2011 13:19:05 +0100
From:	Ben Hutchings <bhutchings@...arflare.com>
To:	dykmanj@...ux.vnet.ibm.com
Cc:	netdev@...r.kernel.org,
	Piyush Chaudhary <piyushc@...ux.vnet.ibm.com>,
	Fu-Chung Chang <fcchang@...ux.vnet.ibm.com>,
	"William S. Cadden" <wscadden@...ux.vnet.ibm.com>,
	"Wen C. Chen" <winstonc@...ux.vnet.ibm.com>,
	Scot Sakolish <sakolish@...ux.vnet.ibm.com>,
	Jian Xiao <jian@...ux.vnet.ibm.com>,
	"Carol L. Soto" <clsoto@...ux.vnet.ibm.com>,
	"Sarah J. Sheppard" <sjsheppa@...ux.vnet.ibm.com>
Subject: Re: [PATCH v2 02/27] HFI: Add HFI adapter control structure

On Sun, 2011-04-17 at 23:21 -0400, dykmanj@...ux.vnet.ibm.com wrote:
> From: Jim Dykman <dykmanj@...ux.vnet.ibm.com>
> 
> Alloc/free of hfidd_acs to track the state of each HFI
[...]
> --- /dev/null
> +++ b/drivers/net/hfi/core/hfidd_adpt.c
[...]
> +int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t devno, void *uiop)
> +{
> +
> +	struct hfidd_acs	*p_acs = NULL;
> +
> +	p_acs = kzalloc(sizeof(*p_acs), GFP_KERNEL);
> +	if (p_acs == NULL)
> +		return -ENOMEM;
> +
> +	p_acs->dev_num = devno;
> +	p_acs->index  = MINOR(devno);
> +	p_acs->state  = HFI_INVALID;
> +	snprintf(p_acs->name, HFI_DEVICE_NAME_MAX - 1,
> +			"%s%d", HFIDD_DEV_NAME, p_acs->index);

snprintf() always null-terminates so the buffer length should be
specified as HFI_DEVICE_NAME_MAX or sizeof(p_acs->name).

[...]
> --- a/drivers/net/hfi/core/hfidd_init.c
> +++ b/drivers/net/hfi/core/hfidd_init.c
[...]
>  static int __init hfidd_mod_init(void)
>  {
>  	int			rc = 0;
>  
> +	hfidd_global.acs_cnt = 0;
> +
>  	rc = hfidd_create_class();
>  	if (rc < 0) {
>  		printk(KERN_ERR "%s: hfidd_mod_init: hfidd_create_class failed"
> @@ -129,12 +172,26 @@ static int __init hfidd_mod_init(void)
>  		return -1;
>  	}
>  
> +	rc = hfidd_create_devices();
> +	if (rc < 0) {
> +		printk(KERN_ERR "%s: hfidd_mod_init: hfidd_create_devices"
> +			" failed rc = %d\n", HFIDD_DEV_NAME, rc);
> +		goto error1;
> +	}
> +
>  	printk(KERN_INFO "IBM hfi device driver loaded sucessfully\n");
>  	return 0;
> +
> +error1:
> +	hfidd_destroy_class();
> +
> +	/* Returning -1 so insmod will fail */
> +	return -1;
>  }
[...]

Should be 'return rc'.  Never return -1 as a generic failure; it means
-EPERM.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ