lkml.org 
[lkml]   [2006]   [Jul]   [28]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    DateFri, 28 Jul 2006 10:35:32 +0200
    FromFrederik Deweerdt <>
    Subject[mm-patch] bluetooth: use GFP_ATOMIC in *_sock_create's sk_alloc
    On Thu, Jul 27, 2006 at 01:56:39AM -0700, Andrew Morton wrote:
    > 
    > ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.18-rc2/2.6.18-rc2-mm1/
    > 
    Hi,
    
    I think that the bluetooth-guard-bt_proto-with-rwlock.patch introduced the following
    BUG:
    [   43.232000] BUG: sleeping function called from invalid context at mm/slab.c:2903
    [   43.232000] in_atomic():1, irqs_disabled():0
    [   43.232000]  [<c0104114>] show_trace_log_lvl+0x197/0x1ba
    [   43.232000]  [<c010415e>] show_trace+0x27/0x29
    [   43.232000]  [<c010426e>] dump_stack+0x26/0x28
    [   43.232000]  [<c011ad1c>] __might_sleep+0xa2/0xaa
    [   43.232000]  [<c0173085>] __kmalloc+0x9c/0xb3
    [   43.232000]  [<c02f9295>] sk_alloc+0x1bc/0x1de
    [   43.232000]  [<c036d689>] hci_sock_create+0x42/0x8a
    [   43.236000]  [<c0366f40>] bt_sock_create+0xb5/0x154
    [   43.236000]  [<c02f69dc>] __sock_create+0x131/0x356
    [   43.236000]  [<c02f6c2f>] sock_create+0x2e/0x30
    [   43.236000]  [<c02f6c88>] sys_socket+0x27/0x53
    [   43.240000]  [<c02f7db5>] sys_socketcall+0xa9/0x277
    [   43.240000]  [<c0103131>] sysenter_past_esp+0x56/0x8d
    [   43.240000]  [<b7f38410>] 0xb7f38410
    
    This patch makes sk_alloc GFP_ATOMIC, because we are holding the bt_proto_rwlock, for
    the following functions:
    - bnep_sock_create
    - cmtp_sock_create
    - hci_sock_create
    - hidp_sock_create
    - l2cap_sock_create
    - rfcomm_sock_create
    - sco_sock_create
    
    Regards,
    Frederik
    
    Signed-off-by: Frederik Deweerdt <frederik.deweerdt@gmail.com>
    
    
    diff -x'*.o' -pruN v2.6.18-rc2-mm1~ori/net/bluetooth/bnep/sock.c v2.6.18-rc2-mm1/net/bluetooth/bnep/sock.c
    --- v2.6.18-rc2-mm1~ori/net/bluetooth/bnep/sock.c	2006-07-27 11:45:45.000000000 +0200
    +++ v2.6.18-rc2-mm1/net/bluetooth/bnep/sock.c	2006-07-28 10:18:34.000000000 +0200
    @@ -181,7 +181,7 @@ static int bnep_sock_create(struct socke
     	if (sock->type != SOCK_RAW)
     		return -ESOCKTNOSUPPORT;
     
    -	sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, &bnep_proto, 1);
    +	sk = sk_alloc(PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto, 1);
     	if (!sk)
     		return -ENOMEM;
     
    diff -x'*.o' -pruN v2.6.18-rc2-mm1~ori/net/bluetooth/cmtp/sock.c v2.6.18-rc2-mm1/net/bluetooth/cmtp/sock.c
    --- v2.6.18-rc2-mm1~ori/net/bluetooth/cmtp/sock.c	2006-07-27 11:45:45.000000000 +0200
    +++ v2.6.18-rc2-mm1/net/bluetooth/cmtp/sock.c	2006-07-28 10:18:49.000000000 +0200
    @@ -172,7 +172,7 @@ static int cmtp_sock_create(struct socke
     	if (sock->type != SOCK_RAW)
     		return -ESOCKTNOSUPPORT;
     
    -	sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, &cmtp_proto, 1);
    +	sk = sk_alloc(PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto, 1);
     	if (!sk)
     		return -ENOMEM;
     
    diff -x'*.o' -pruN v2.6.18-rc2-mm1~ori/net/bluetooth/hci_sock.c v2.6.18-rc2-mm1/net/bluetooth/hci_sock.c
    --- v2.6.18-rc2-mm1~ori/net/bluetooth/hci_sock.c	2006-07-27 11:45:45.000000000 +0200
    +++ v2.6.18-rc2-mm1/net/bluetooth/hci_sock.c	2006-07-28 09:28:48.000000000 +0200
    @@ -618,7 +618,7 @@ static int hci_sock_create(struct socket
     
     	sock->ops = &hci_sock_ops;
     
    -	sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, &hci_sk_proto, 1);
    +	sk = sk_alloc(PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto, 1);
     	if (!sk)
     		return -ENOMEM;
     
    diff -x'*.o' -pruN v2.6.18-rc2-mm1~ori/net/bluetooth/hidp/sock.c v2.6.18-rc2-mm1/net/bluetooth/hidp/sock.c
    --- v2.6.18-rc2-mm1~ori/net/bluetooth/hidp/sock.c	2006-07-27 11:45:45.000000000 +0200
    +++ v2.6.18-rc2-mm1/net/bluetooth/hidp/sock.c	2006-07-28 10:19:03.000000000 +0200
    @@ -178,7 +178,7 @@ static int hidp_sock_create(struct socke
     	if (sock->type != SOCK_RAW)
     		return -ESOCKTNOSUPPORT;
     
    -	sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, &hidp_proto, 1);
    +	sk = sk_alloc(PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto, 1);
     	if (!sk)
     		return -ENOMEM;
     
    diff -x'*.o' -pruN v2.6.18-rc2-mm1~ori/net/bluetooth/l2cap.c v2.6.18-rc2-mm1/net/bluetooth/l2cap.c
    --- v2.6.18-rc2-mm1~ori/net/bluetooth/l2cap.c	2006-07-27 11:45:45.000000000 +0200
    +++ v2.6.18-rc2-mm1/net/bluetooth/l2cap.c	2006-07-28 10:09:12.000000000 +0200
    @@ -559,7 +559,7 @@ static int l2cap_sock_create(struct sock
     
     	sock->ops = &l2cap_sock_ops;
     
    -	sk = l2cap_sock_alloc(sock, protocol, GFP_KERNEL);
    +	sk = l2cap_sock_alloc(sock, protocol, GFP_ATOMIC);
     	if (!sk)
     		return -ENOMEM;
     
    diff -x'*.o' -pruN v2.6.18-rc2-mm1~ori/net/bluetooth/rfcomm/sock.c v2.6.18-rc2-mm1/net/bluetooth/rfcomm/sock.c
    --- v2.6.18-rc2-mm1~ori/net/bluetooth/rfcomm/sock.c	2006-07-27 11:45:45.000000000 +0200
    +++ v2.6.18-rc2-mm1/net/bluetooth/rfcomm/sock.c	2006-07-28 10:16:59.000000000 +0200
    @@ -336,7 +336,7 @@ static int rfcomm_sock_create(struct soc
     
     	sock->ops = &rfcomm_sock_ops;
     
    -	if (!(sk = rfcomm_sock_alloc(sock, protocol, GFP_KERNEL)))
    +	if (!(sk = rfcomm_sock_alloc(sock, protocol, GFP_ATOMIC)))
     		return -ENOMEM;
     
     	rfcomm_sock_init(sk, NULL);
    diff -x'*.o' -pruN v2.6.18-rc2-mm1~ori/net/bluetooth/sco.c v2.6.18-rc2-mm1/net/bluetooth/sco.c
    --- v2.6.18-rc2-mm1~ori/net/bluetooth/sco.c	2006-07-27 11:45:45.000000000 +0200
    +++ v2.6.18-rc2-mm1/net/bluetooth/sco.c	2006-07-28 10:11:28.000000000 +0200
    @@ -452,7 +452,7 @@ static int sco_sock_create(struct socket
     
     	sock->ops = &sco_sock_ops;
     
    -	if (!(sk = sco_sock_alloc(sock, protocol, GFP_KERNEL)))
    +	if (!(sk = sco_sock_alloc(sock, protocol, GFP_ATOMIC)))
     		return -ENOMEM;
     
     	sco_sock_init(sk, NULL);
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    
    \
     
     \ /
      Last update: 2006-07-28 10:39    [from the cache]
    ©2003-2008