提交 b68dbcab 编写于 作者: V Vlad Yasevich 提交者: David S. Miller

[SCTP]: Fix warning

An alternate solution would be to make the digest a pointer, allocate
it in sctp_endpoint_init() and free it in sctp_endpoint_destroy().

I guess I should have originally done it this way...

  CC [M]  net/sctp/sm_make_chunk.o
net/sctp/sm_make_chunk.c: In function 'sctp_unpack_cookie':
net/sctp/sm_make_chunk.c:1358: warning: initialization discards qualifiers from pointer target type

The reason is that sctp_unpack_cookie() takes a const struct
sctp_endpoint and modifies the digest in it (digest being embedded in
the struct, not a pointer).  Make digest a pointer to fix this
warning.
Signed-off-by: NVlad Yasevich <vladislav.yasevich@hp.com>
Acked-by: NSridhar Samudrala <sri@us.ibm.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 9ec75fe8
...@@ -1270,7 +1270,7 @@ struct sctp_endpoint { ...@@ -1270,7 +1270,7 @@ struct sctp_endpoint {
* this here so we pre-allocate this once and can re-use * this here so we pre-allocate this once and can re-use
* on every receive. * on every receive.
*/ */
__u8 digest[SCTP_SIGNATURE_SIZE]; __u8 *digest;
/* sendbuf acct. policy. */ /* sendbuf acct. policy. */
__u32 sndbuf_policy; __u32 sndbuf_policy;
......
...@@ -72,6 +72,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, ...@@ -72,6 +72,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
{ {
memset(ep, 0, sizeof(struct sctp_endpoint)); memset(ep, 0, sizeof(struct sctp_endpoint));
ep->digest = kzalloc(SCTP_SIGNATURE_SIZE, gfp);
if (!ep->digest)
return NULL;
/* Initialize the base structure. */ /* Initialize the base structure. */
/* What type of endpoint are we? */ /* What type of endpoint are we? */
ep->base.type = SCTP_EP_TYPE_SOCKET; ep->base.type = SCTP_EP_TYPE_SOCKET;
...@@ -182,6 +186,9 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep) ...@@ -182,6 +186,9 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
/* Free up the HMAC transform. */ /* Free up the HMAC transform. */
crypto_free_hash(sctp_sk(ep->base.sk)->hmac); crypto_free_hash(sctp_sk(ep->base.sk)->hmac);
/* Free the digest buffer */
kfree(ep->digest);
/* Cleanup. */ /* Cleanup. */
sctp_inq_free(&ep->base.inqueue); sctp_inq_free(&ep->base.inqueue);
sctp_bind_addr_free(&ep->base.bind_addr); sctp_bind_addr_free(&ep->base.bind_addr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册