From: Ursula Braun <[email protected]>
Date: Thu, 24 Nov 2016 16:06:32 +0100
> +static struct sock *smc_sock_alloc(struct net *net, struct socket *sock)
> +{
> + struct smc_sock *smc;
> + struct sock *sk;
> +
> + sk = sk_alloc(net, PF_SMC, GFP_KERNEL, &smc_proto, 0);
> + if (!sk)
> + return NULL;
> +
> + sock_init_data(sock, sk); /* sets sk_refcnt to 1 */
> + sk->sk_state = SMC_INIT;
> + sk->sk_destruct = smc_destruct;
> + sk->sk_protocol = SMCPROTO_SMC;
> + sk_refcnt_debug_inc(sk);
> +
> + smc = smc_sk(sk);
> + smc->clcsock = NULL;
> + smc->use_fallback = 0;
This is unnecessary, sk_alloc() clears out the memory for you.
> +static int smc_bind(struct socket *sock, struct sockaddr *uaddr,
> + int addr_len)
> +{
...
> + smc->clcsock->sk->sk_reuse = sk->sk_reuse;
> + rc = kernel_bind(smc->clcsock, uaddr, addr_len);
Is it valid to assume smc->clcsock is not NULL right here?
> +struct smc_sock { /* smc sock container */
> + struct sock sk;
> + struct socket *clcsock; /* internal tcp socket */
> + u8 use_fallback : 1; /* fallback to tcp */
> +};
Please use 'bool' and true/false for 'use_fallback'.