[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4DB0A3DF.50900@linux.vnet.ibm.com>
Date: Thu, 21 Apr 2011 17:38:39 -0400
From: Jim Dykman <dykmanj@...ux.vnet.ibm.com>
To: Ben Hutchings <bhutchings@...arflare.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 4/18/2011 8:19 AM, Ben Hutchings wrote:
> 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).
>
Ok.
> [...]
>> --- 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.
>
Ok
> Ben.
>
Jim
--
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