Re: insmod "Device or resource busy" errors - Regarding

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

 



In function:

int 
 hostQueryModuleInit    
        (
        void
        )
        {
        if (!pci_present ())
                {
                printk
                        (
                        KERN_WARNING "%s.%d::No pci... Aborting.\n", 
                        __FILE__,
                        __LINE__
                        );
                return -1;
                }
        
        printk
                (
                KERN_INFO "After pci_present\n"
                );

        //      ... Get dynamic major number from kernel
        queryMajorNum = register_chrdev (0, "queryd", &queryDevice_fops);
                
        printk
                (
                KERN_INFO "After register_chrdev\n"
                );

        if (queryMajorNum < 0)
                {
                printk 
                        (
                        KERN_ERR "%s.%d::register_chrdev(%s) returned (%d)...\n", 
                        __FILE__,
                        __LINE__,
                        "queryd", 
                        queryMajorNum
                        );
                        
                return queryMajorNum;
                }
        
        queryDevRegistered = 1;

        //hostQueryRegisterSymbols ();  

        printk
                (
                KERN_INFO "After hostQueryRegisterSymbols:%u \n",
                queryMajorNum
                );

/*WRONG!!!*/        return queryMajorNum;
/*MUST BE:          return 0;
        }


If register_chrdev success you don't need to return queryMajorNum,
as a general rule:
if a module intialization function you need to return 0 if everything success, !=0 if fail.

You module is wrong because you register a chrdev, and this success... but because of
your module_init return !=0 init_module fails without releasing resources allocated.

Hope this help.







-------------------------------------------------------------------------------------------------------------------------------------------------------------
PGP PKEY      http://pgp.mit.edu:11371/pks/lookup?search=belch76@libero.it&op=index
ICQ#               104896040  
Netphone/Fax  178.605.7063
Homepage       http://web.tiscali.it/bellucda
-------------------------------------------------------------------------------------------------------------------------------------------------------------

Daniele Bellucci



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux