c - Memory leak by using ksocket -


i write simple kernel module include following ksocket connection accept codes:

.....(some ksocket initiation)  while( on_service ) {     sockfd_c = kaccept(sockfd_s, (struct sockaddr *)&addr_cli, &addr_len);     kclose(sockfd_c); } 

and write simple client connect socket server. console, found memory usage increasing "free" command when continuously run client connection.

the functions of kaccept() , kclose() follows.

int kclose(ksocket_t sockfd)                                                                                                                                                                                      {     struct socket *sk;     int ret;      sk = (struct socket *)sockfd;     ret = sk->ops->release(sk);      if (sk)     {            sock_release(sk);     }         return ret; }  ksocket_t kaccept(ksocket_t socket, struct sockaddr *address, int *address_len) {     struct socket *sk;     struct socket *new_sk = null;     int ret;      sk = (struct socket *)socket;      sxg_debug("family = %d, type = %d, protocol = %d\n",                 sk->sk->sk_family, sk->type, sk->sk->sk_protocol);     //new_sk = sock_alloc();     //sock_alloc() not exported, use sock_create() instead     ret = sock_create(sk->sk->sk_family, sk->type, sk->sk->sk_protocol, &new_sk);     if (ret < 0)         return null;     if (!new_sk)         return null;      new_sk->type = sk->type;     new_sk->ops = sk->ops;      ret = sk->ops->accept(sk, new_sk, 0 /*sk->file->f_flags*/);     if (ret < 0)         goto error_kaccept;      if (address)     {         ret = new_sk->ops->getname(new_sk, address, address_len, 2);         if (ret < 0)             goto error_kaccept;     }      return new_sk;  error_kaccept:     sock_release(new_sk);     return null; } 

does there know why/how memory leak?

use valgrind find memory leaks

as

valgrind ./your_program 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -