急:printk崩溃?

发布于 2022-10-15 05:04:16 字数 6287 浏览 18 评论 0

在做个驱动,不知道为什么malloc了几个包之后就会崩溃?找不到原因,望各位赐教!

L01BehavPack* L01Behav_mallocPack( unsigned int direction )
{
        L01BehavPack *newPack = kmalloc( sizeof(L01BehavPack), GFP_ATOMIC );
        if( newPack == NULL )
                return NULL;
        memset( newPack , 0 , sizeof(L01BehavPack) );

        if( direction == L01_behav_direction_out )
        {
                newPack -> buf[0] = COM_WriteFifo;
                newPack -> flag = L01_behav_flag_out;
        }
        else
        {
                newPack -> buf[0] = COM_ReadFifo;
                newPack -> flag = L01_behav_flag_in;
        }
        newPack -> bufSize = 33;

        return newPack;
}

[root@FriendlyARM /opt]# <1>Unable to handle kernel NULL pointer dereference at virtual address 00000001
pgd = c3a64000
[00000001] *pgd=338bd031, *pte=00000000, *ppte=00000000
Internal error: Oops: 13 [#1]
Modules linked in: wirelessNet
CPU: 0    Not tainted  (2.6.29.4-FriendlyARM #3)
PC is at kmem_cache_alloc+0x38/0x90
LR is at L01Behav_mallocSysPack+0x4c/0x12c [wirelessNet]
pc : [<c0085938>]    lr  Qs off  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: c000717f  Table: 33a64000  DAC: 00000017
Process L01Behav_intThr (pid: 548, stack limit = 0xc3a5426
Stack: (0xc3a55d38 to 0xc3a56000)
5d20:                                                       c003acec c3a55d48
5d40: c3a54000 00000001 c3a55d48 c3a55d48 c3a55d6c c3a55d60 c002d20c c003dddc
5d60: c3a55d8c c3a55d70 c002f3f8 c002cfd8 c3a55f20 00000003 c3a55f20 c03ff430
5d80: c3a55e24 c3a55d90 c002f6ac c002f39c c3827fa4 00000000 c3812048 ffffffff
5da0: c3a55df8 c3a55f20 c03ff430 c3a55f20 c0085938 c3a55e24 c3a55dc4 c0028a00
5dc0: c00281b8 00000001 00000001 c3a55f20 00000001 e7942103 e7942103 c3a55f20
5de0: c03ff430 c3a55f20 00000001 c0085938 c3a55e24 00000002 c3a55e0c c0030f88
5e00: c02d5be8 00000093 ffffffff 00000000 00000000 e7942103 c3a55e6c c3a55e28
5e20: c0030df4 c002f674 c3a55e54 c3a55e38 c0032764 c0060f04 00000015 00000013
5e40: c3a55f40 c03d0614 c3a55f54 00000013 c03d0644 c3a55f20 20000093 00000001
5e60: c3a55f1c c3a55e70 c00281e4 c0030d60 c0028a44 c0028010 0000003f c3abf3c0
5e80: 00020102 40000013 c3abf3c0 c3abf3c0 0000003f 0000003f c03ff8c0 00000001
5ea0: c3a54000 c3a55edc c3a55ee0 c3a55ec0 c3a55edc c3a55ec0 c03d5cf8 c3abf3c0
5ec0: 0000003f c0422ef0 c03ff8c0 c3a54000 c3a55efc c3a55ee0 c0060fb4 c0060728
5ee0: 0000003f 00000000 00000001 c384d75c c3a55f1c c3a55f00 ffffffff c3a55f54
5f00: 00000020 00000040 000000ff 00000000 c3a55f8c c3a55f20 c0028a00 c00281b8
5f20: c03ce378 00000020 20000093 00000000 00000001 20000013 00000020 00000040
5f40: 000000ff 00000000 00000000 c3a55f8c c3a55f90 c3a55f68 bf0003a8 c0085938
5f60: 20000093 ffffffff bf002e44 00000002 bf002e44 bf003118 bf002e44 00000007
5f80: c3a55fb4 c3a55f90 bf0003a8 c0085910 bf002e44 00000002 bf000dfc c0421d10
5fa0: 00000000 00000000 c3a55fd4 c3a55fb8 bf000e50 bf00036c 00000002 00000000
5fc0: c3a54000 bf002e44 c3a55ff4 c3a55fd8 c004fa64 bf000e0c 00000000 00000000
5fe0: 00000000 00000000 00000000 c3a55ff8 c003ddcc c004fa14 00000000 00000000
Backtrace:
[<c003ddcc>] (do_exit+0x0/0x730) from [<c002d20c>] (die+0x244/0x2ac)
[<c002cfc8>] (die+0x0/0x2ac) from [<c002f3f8>] (__do_kernel_fault+0x6c/0x7c)
[<c002f38c>] (__do_kernel_fault+0x0/0x7c) from [<c002f6ac>] (do_bad_area+0x48/0x90)
r7:c03ff430 r6:c3a55f20 r5:00000003 r4:c3a55f20
[<c002f664>] (do_bad_area+0x0/0x90) from [<c0030df4>] (do_alignment+0xa4/0x354)
r5:e7942103 r4:00000000
[<c0030d50>] (do_alignment+0x0/0x354) from [<c00281e4>] (do_DataAbort+0x3c/0xa0)
[<c00281a8>] (do_DataAbort+0x0/0xa0) from [<c0028a00>] (__dabt_svc+0x40/0x60)
Exception stack(0xc3a55f20 to 0xc3a55f6
5f20: c03ce378 00000020 20000093 00000000 00000001 20000013 00000020 00000040
5f40: 000000ff 00000000 00000000 c3a55f8c c3a55f90 c3a55f68 bf0003a8 c0085938
5f60: 20000093 ffffffff                                                      
[<c0085900>] (kmem_cache_alloc+0x0/0x90) from [<bf0003a8>] (L01Behav_mallocSysPack+0x4c/0x12c [wirelessNet])
r7:00000007 r6:bf002e44 r5:bf003118 r4:bf002e44
[<bf00035c>] (L01Behav_mallocSysPack+0x0/0x12c [wirelessNet]) from [<bf000e50>] (L01Behav_intThread+0x54/0x88 [wirelessNet])
[<bf000dfc>] (L01Behav_intThread+0x0/0x88 [wirelessNet]) from [<c004fa64>] (kthread+0x60/0x94)
r5:bf002e44 r4:c3a54000
[<c004fa04>] (kthread+0x0/0x94) from [<c003ddcc>] (do_exit+0x0/0x730)
r7:00000000 r6:00000000 r5:00000000 r4:00000000
Code: e59700f0 e3a01000 ebfff8f8 eaffff92 (e5908010)
---[ end trace b3595b963a1fe77f ]---

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

作死小能手 2022-10-22 05:04:16

看看这几个地址是什么

               newPack -> buf[0]
               newPack -> flag
               newPack -> bufSize

我觉得可能这个buf是0长数组,导致buf的地址没有分配,下标越界

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文