request_region checks.

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

 



Hi,

I've been looking through some of the device drivers and find quite often a call
to request_region of the form:

	if (!request_region(IO_INDEX_PORT, 2, WATCHDOG_NAME))
	{
		printk(KERN_ERR PFX "I/O address 0x%04x already in use\n",
			IO_INDEX_PORT);
		rc = -EIO;
		goto err_out;
	}

I was interested in finding out what happens to the pointer which is returned
from request_region. This if statement simply interests itself with the case of
request_region returning NULL and makes no consideration that a pointer may be
returned.

The request_region is a macro which maps onto __request_region. In this
function, a pointer to struct resource is allocated memory via kzalloc. This is
done right at the begining of the __request_region function. The function
__request_region itself calls the function __request_resource and on this
returning a NULL value, then the pointer to the memory allocated via kzalloc is
returned.

So, if the above if statement is != NULL, then who looks after freeing up the
pointer which was returned?

I must be missing something, as calls of this form are done a lot in drivers.

Cheers, Mark.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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