Hi,
Is it possible to allocate to allocate memory for char * variable defined in user program from
kernel module.
I would put things in detail with the below code.
The below code is part of character driver . "xxx_read" function is called by a user program passing
a char * pointer (buf in below code).
Code:
ssize_t xxx_read (struct file *filp, char *buf, size_t count, loff_t *pos)
{
printk("PROCESS %i (%s) GOING TO SLEEP\n",current->pid, current->comm);
interruptible_sleep_on(waitQueueRef);
// initialize 'modifiedFile"
// can i use: buf = (char *) kmalloc(sizeof(modifiedFile), GFP_KERNEL);
copy_to_user(buf,modifiedFile,strlen(modifiedFile));
return 0;
}
What i need is whether i can use kmalloc for the variable "buf" inside the "xxx_read" and free the
memory using "free" in my user program which calls the kernel read function.