Hi, I create two modules modA and modB (real files attached below: modA.c, modB.c and modA.h). I intend to make them work like this: - "insmod modA.o" will initialze the array of struct, pA[0], pA[1] and pA[2]. - "insmod modB.o" will call the function modA_func_1(ptr) defined in modA, which copies the the pointers "ptr = pA". I assume I should see the following 3 line on the console: ################ ptr[0].i=0 ################ ptr[1].i=10 ################ ptr[2].i=20 But I only see 3 ramdom numbers (not 0, 10, 20). This means modA_func_1(ptr) defined in modA doesn't do "ptr = pA" correctly, or somehow the ptr value gets changed when function modA_func_1(ptr) returns. What I missed and how to pass an array of struct from one module to another? Thanks, T. /*************** modA.c ******************** #define MODULE #include <linux/module.h> #include "modA.h" int init_module(void) { printk("<0>Hello, world from modA\n"); return 0; } void modA_func_1(void * ptr) { A_struct *pA; int i; pA = (A_struct *) kmalloc(3*sizeof(A_struct)); for(i=0; i<3; i++) pA[0].i = i * 10; ptr = pA; } EXPORT_SYMBOL_NOVERS(modA_func_1); void cleanup_module(void) { printk("<0>Goodbye world from modA\n"); } /****************** modB.c *******************/ #define MODULE #include <linux/module.h> #include "modA.h" extern void modA_func_1(struct A *ptr); int init_module(void) { A_struct * ptr; int i; ptr = (A_struct *) kmalloc(3*sizeof(A_struct)); modA_func_1(ptr); for(i=0; i<3; i++) printk("<0>################ ptr[%d].i=%d\n", i, ptr[i].i); return 0; } void cleanup_module(void) { printk("<0>Goodbye world from modB\n"); } /*************** modA.h **********************/ typedef struct A { int i; char c; } A_struct; __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/