From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753737AbbC0Iql (ORCPT ); Fri, 27 Mar 2015 04:46:41 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35396 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753423AbbC0Iqe (ORCPT ); Fri, 27 Mar 2015 04:46:34 -0400 Date: Fri, 27 Mar 2015 09:46:30 +0100 From: Greg Kroah-Hartman To: Sudip Mukherjee Cc: Benjamin Romer , David Kershner , sparmaintainer@unisys.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] staging: unisys: unregister chardev on error Message-ID: <20150327084630.GA1250@kroah.com> References: <1427445059-9534-1-git-send-email-sudipm.mukherjee@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1427445059-9534-1-git-send-email-sudipm.mukherjee@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 27, 2015 at 02:00:57PM +0530, Sudip Mukherjee wrote: > after registering the major numbers if the cdev_add fails then we were > not releasing the major numbers. now we are doing that. > > Signed-off-by: Sudip Mukherjee > --- > drivers/staging/unisys/visorchipset/file.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c > index 39b19af..074c285 100644 > --- a/drivers/staging/unisys/visorchipset/file.c > +++ b/drivers/staging/unisys/visorchipset/file.c > @@ -65,8 +65,10 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel) > return -1; > } > rc = cdev_add(&file_cdev, MKDEV(MAJOR(major_dev), 0), 1); > - if (rc < 0) > + if (rc < 0) { Care to delete the extra space while you are modifying this line? > + unregister_chrdev_region(major_dev, 1); > return -1; It's not your fault, and don't change this, but something that needs to be fixed up in the future are these "random" negative numbers being returned. Use proper -ERROR #defines instead. thanks, greg k-h