[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: KernelNewbies Wikki
Hemant/ Sanjay,
Sanjay is talking about the fact that, in the "loading" function itself
the semaphore is made up although it has not been "sema_init".
That said I think they are just "idiot modules" that have been put in
and of course may not work really perfectly.
Thanks,
Vishwas
-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx
[mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Hemant Mohapatra
Sent: Friday, July 01, 2005 10:55 AM
To: Sanjay Kumar, Noida
Cc: kernelnewbies@xxxxxxxxxxxx
Subject: Re: KernelNewbies Wikki
On 7/1/05, Sanjay Kumar, Noida <sanjayku@xxxxxxxxxxx> wrote:
> Hi,
> if the kmalloc fails for hello_msg, why do we need to release
> the semaphore.This is the code snippet:
> if (!hello_msg){
> up(&hello_sem);
> return -ENOMEM;
> }
Please read the code carefully again:
static ssize_t hello_write(struct inode *inode, const char __user
*user_buf, size_t len, loff_t offset)
{
..
down(&hello_sem); --> semaphore initialized here.
if (hello_msg) {
kfree(hello_msg);
hello_msg = kmalloc(len+1, GFP_KERNEL);
if (!hello_msg) {
up(&hello_sem); --> if fails, change back to
original semval and return
return -ENOMEM;
..
}
Where is the problem?
./h
www.embedded-tutorials.com - Embedded Linux Tutorials
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/