This is code which fails when video_register_device is called. It does nothing
particular. It just tries to call that function when the module is loaded into
the memory. I really don't know where is the error...
Below there are also the kernel message and the ksymoops output about it. The
kernel version is 2.4.20 on an i686 processor. I also tried with 2.4.19.
/* BEGIN */
#define MODULE
#define __KERNEL__
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/videodev.h>
struct my_device {
struct video_device v4ldev; /* V4L structure */
};
static int my_open(struct inode* inode, struct file* filp)
{
return -1;
}
static int my_release(struct inode* inode, struct file* filp)
{
return 0;
}
static ssize_t my_read(struct file* filp, char* buf,
size_t count, loff_t* f_pos)
{
return 0;
}
static unsigned int my_poll(struct file* filp, poll_table* wait)
{
return 0;
}
static int my_mmap(struct file* filp, struct vm_area_struct *vma)
{
return -1;
}
static int my_ioctl(struct inode* inode, struct file* filp,
unsigned int cmd, unsigned long arg)
{
return -1;
}
struct file_operations my_fops = {
open: my_open,
release: my_release,
read: my_read,
ioctl: my_ioctl,
poll: my_poll,
mmap: my_mmap,
owner: THIS_MODULE
};
int my_probe()
{
struct my_device* camera;
int err = 0;
printk(KERN_DEBUG "mydev: Probe called.\n");
camera = (struct my_device*)
kmalloc(sizeof(struct my_device), GFP_KERNEL);
if (!camera) {
printk(KERN_WARNING "mydev: couldn't allocate memory\n");
goto fail;
}
strcpy(camera->v4ldev.name, "MYDEV");
camera->v4ldev.type = VID_TYPE_CAPTURE;
camera->v4ldev.hardware = 1000; /* whatever ? */
camera->v4ldev.fops = &my_fops;
camera->v4ldev.priv = NULL;
camera->v4ldev.minor = -1;
printk(KERN_DEBUG "mydev: Calling video_register_device..\n");
err = video_register_device(&camera->v4ldev,VFL_TYPE_GRABBER, -1);
if (err) {
printk(KERN_ERR "mydev: v4l registration failed.\n");
goto fail;
}
printk(KERN_DEBUG "mydev: V4L device registered\n");
return 0;
fail:
if (camera) kfree(camera);
return -1;
}
static int __init my_module_init(void)
{
return my_probe();
}
static void __exit my_module_cleanup(void)
{
}
module_init(my_module_init);
module_exit(my_module_cleanup);
/* END MODULE */
This is the kernel message:
mydev: Probe called.
mydev: Calling video_register_device..
Unable to handle kernel NULL pointer dereference at virtual address 000000b0
printing eip:
000000b0
*pde = 00000000
Oops: 0000
CPU: 0
EIP: 0010:[<000000b0>] Tainted: P
EFLAGS: 00010202
eax: 000000b0 ebx: 00000003 ecx: d0aed1e0 edx: d0aed260
esi: 00000000 edi: cf0e86a0 ebp: 0000000c esp: c1cb7ed0
ds: 0018 es: 0018 ss: 0018
Process insmod (pid: 2425, stackpage=c1cb7000)
Stack: d0aecb0b cf0e86a0 d0aed080 c02f44ea 00000246 0000002a c1cb7f18 cf0e86a0
00000001 00000001 c1cb7f18 d2453130 cf0e86a0 00000000 ffffffff c102c01c
c02933e4 d2453000 c1cb7f28 d245318b 00000001 00000001 00000001 c0119015
Call Trace: [<d0aecb0b>] [<d0aed080>] [<d2453130>] [<d245318b>]
[<c0119015>]
[<d245336c>] [<d2453060>] [<c0106dc3>]
Code: Bad EIP value.
Ksymoops output:
ksymoops 2.4.3 on i686 2.4.20. Options used
-V (default)
-k /proc/ksyms (default)
-l /proc/modules (default)
-o /lib/modules/2.4.20/ (default)
-m /boot/System.map-2.4.20 (default)
>>EIP; 000000b0 Before first symbol <=====
Trace; d0aecb0a <[videodev]video_register_device+13a/1d0>
Trace; d0aed080 <[videodev].text.end+392/4f2>
Trace; d2453130 <[w9968cf2]my_probe+70/c0>
Trace; d245318a <[w9968cf2]my_module_init+a/10>
Trace; c0119014 <sys_init_module+534/5f0>
Trace; d245336c <[w9968cf2].text.end+1ce/202>
Trace; d2453060 <[w9968cf2]my_open+0/10>
Trace; c0106dc2 <system_call+32/38>
--
video4linux-list mailing list
Unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/video4linux-list