All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [patch 2/2] usbhid: fix some error codes in hiddev_connect()
Date: Thu, 26 May 2011 12:58:56 +0000	[thread overview]
Message-ID: <4DDE4E90.1010008@bfs.de> (raw)
In-Reply-To: <20110526085018.GE14591@shale.localdomain>



Am 26.05.2011 14:07, schrieb Jiri Kosina:
> On Thu, 26 May 2011, Dan Carpenter wrote:
> 
>> Returning -1 is -EPERM which is inappropriate here.
>>
>> Signed-off-by: Dan Carpenter <error27@gmail.com>
>>
>> diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
>> index b2f9a3a..80b8e76 100644
>> --- a/drivers/hid/usbhid/hiddev.c
>> +++ b/drivers/hid/usbhid/hiddev.c
>> @@ -890,8 +890,9 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
>>  			return -1;
>>  	}
>>  
>> -	if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
>> -		return -1;
>> +	hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL);
>> +	if (!hiddev)
>> +		return -ENOMEM;
>>  
>>  	init_waitqueue_head(&hiddev->wait);
>>  	INIT_LIST_HEAD(&hiddev->list);
>> @@ -905,7 +906,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
>>  		hid_err(hid, "Not able to get a minor for this device\n");
>>  		hid->hiddev = NULL;
>>  		kfree(hiddev);
>> -		return -1;
>> +		return retval;
>>  	}
>>  	return 0;
>>  }
> 
> Why would that matter?
> 
> hid_connect() (which is the only caller) only checks for the return value 
> being (non-)zero.
> 

this may change in future and it may help in showing the propper error (aka strerror()).

just my two cents,
re,
 wh

      parent reply	other threads:[~2011-05-26 12:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26  8:50 [patch 2/2] usbhid: fix some error codes in hiddev_connect() Dan Carpenter
2011-05-26  8:50 ` Dan Carpenter
2011-05-26 12:07 ` Jiri Kosina
2011-05-26 12:07   ` Jiri Kosina
2011-05-26 16:35   ` Dan Carpenter
2011-05-26 16:35     ` Dan Carpenter
2011-05-26 12:58 ` walter harms [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DDE4E90.1010008@bfs.de \
    --to=wharms@bfs.de \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.