Re: [PATCH] staging: dgnc: Fix a possible crash when the class_create fails

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

 



Hello Dan,

On Wed, Oct 15, 2014 at 2:47 PM, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> On Mon, Oct 13, 2014 at 10:26:54PM +0530, devendranaga4@xxxxxxxxx wrote:
>> From: Devendra Naga <devendranaga4@xxxxxxxxx>
>>
>
> Just fix your email client, so the from header is correct.  These From
> headers should be for when you forward an email from someone else.
>

I am trying to get into kernel development again. I will get this
fixed for the next patch.

-- snip --

>>       /* make sure that the globals are init'd before we do anything else */
>> @@ -271,6 +271,12 @@ static int dgnc_start(void)
>>       dgnc_Major = rc;
>>
>>       dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
>> +     if (IS_ERR(dgnc_class)) {
>> +             rc = PTR_ERR(dgnc_class);
>> +             APR(("Can't creat dgnc class (%d)\n", rc));
>
> No need for an error message here.  The lower levels handle this.
>

Okay. I will remove this print.

>> +             goto bad;
>> +     }
>> +
>>       device_create(dgnc_class, NULL,
>>               MKDEV(dgnc_Major, 0),
>>               NULL, "dgnc_mgmt");
>> @@ -297,6 +303,10 @@ static int dgnc_start(void)
>>       add_timer(&dgnc_poll_timer);
>>
>>       return rc;
>
> This should be "return 0;"
>

Right. The successful execution of the function.


> Add  a goto after dgnc_tty_preinit() while you are at it.  Call the
> patch "fix error handling in dgnc_start()".
>
>> +
>> +bad:
>
> This label is not as useful as could be.  We already know it's "bad"
> when class_create() failed so it doesn't add any new information.
> Call is something like: "err_unregister:".
>

Sure.

>
>> +     unregister_chrdev(dgnc_Major, "dgnc");
>> +     return rc;
>
> regards,
> dan carpenter
>


Thanks for your comments. I will create another patch and send to the
list again taking care of your comments.

Dev
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux