经常会因为内核配置改动了一下,从新编译内核后,如果加载以前的驱动,会导致一些错误。
有时甚者内核挂了。
以前就从新编译一下驱动就完事,但是没深究。
几天看了mutex的实现,呵呵,看到了原因。
如下:
struct mutex {
/* 1: unlocked, 0: locked, negative: locked, possible waiters */
atomic_t count;
spinlock_t wait_lock;
struct list_head wait_list;
#ifdef CONFIG_DEBUG_MUTEXES
struct thread_info *owner;
const char *name;
void *magic;
#endif
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lockdep_map dep_map;
#endif
};
内核的配置不同,会有以下四种结果:
如果,驱动在CONFIG_DEBUG_MUTEXES跟CONFIG_DEBUG_LOCK_ALLOC都没配置的情况下编译,但是后来内核将CONFIG_DEBUG_MUTEXES跟CONFIG_DEBUG_LOCK_ALLOC都加上,那么,肯定会越界访问了。
struct mutex {
/* 1: unlocked, 0: locked, negative: locked, possible waiters */
atomic_t count;
spinlock_t wait_lock;
struct list_head wait_list;
};
struct mutex {
/* 1: unlocked, 0: locked, negative: locked, possible waiters */
atomic_t count;
spinlock_t wait_lock;
struct list_head wait_list;
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lockdep_map dep_map;
#endif
};
struct mutex {
/* 1: unlocked, 0: locked, negative: locked, possible waiters */
atomic_t count;
spinlock_t wait_lock;
struct list_head wait_list;
#ifdef CONFIG_DEBUG_MUTEXES
struct thread_info *owner;
const char *name;
void *magic;
#endif
};
struct mutex {
/* 1: unlocked, 0: locked, negative: locked, possible waiters */
atomic_t count;
spinlock_t wait_lock;
struct list_head wait_list;
#ifdef CONFIG_DEBUG_MUTEXES
struct thread_info *owner;
const char *name;
void *magic;
#endif
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lockdep_map dep_map;
#endif
};
如果改变你内核的配置,最好从新编译一下你的驱动!!!
阅读(2542) | 评论(0) | 转发(0) |