[PATCH] iov_iter: Fix build error without CONFIG_CRYPTO

From: Yue Haibing
Date: Wed Apr 03 2019 - 05:51:01 EST


From: YueHaibing <yuehaibing@xxxxxxxxxx>

If CONFIG_CRYPTO is not set or set to m,
gcc building warn this:

lib/iov_iter.o: In function `hash_and_copy_to_iter':
iov_iter.c:(.text+0x9129): undefined reference to `crypto_stats_get'
iov_iter.c:(.text+0x9152): undefined reference to `crypto_stats_ahash_update'

Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
Fixes: d05f443554b3 ("iov_iter: introduce hash_and_copy_to_iter helper")
Signed-off-by: YueHaibing <yuehaibing@xxxxxxxxxx>
---
include/linux/skbuff.h | 2 ++
lib/iov_iter.c | 2 ++
net/core/datagram.c | 2 ++
3 files changed, 6 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 9027a8c..3999112 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3396,9 +3396,11 @@ static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset,
}
int skb_copy_and_csum_datagram_msg(struct sk_buff *skb, int hlen,
struct msghdr *msg);
+#ifdef CONFIG_CRYPTO
int skb_copy_and_hash_datagram_iter(const struct sk_buff *skb, int offset,
struct iov_iter *to, int len,
struct ahash_request *hash);
+#endif
int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
struct iov_iter *from, int len);
int zerocopy_sg_from_iter(struct sk_buff *skb, struct iov_iter *frm);
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 50e77ec..ed02f74 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1528,6 +1528,7 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump,
}
EXPORT_SYMBOL(csum_and_copy_to_iter);

+#ifdef CONFIG_CRYPTO
size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,
struct iov_iter *i)
{
@@ -1542,6 +1543,7 @@ size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,
return copied;
}
EXPORT_SYMBOL(hash_and_copy_to_iter);
+#endif

int iov_iter_npages(const struct iov_iter *i, int maxpages)
{
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 91bb5a0..8815ec2 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -494,6 +494,7 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
return 0;
}

+#ifdef CONFIG_CRYPTO
/**
* skb_copy_and_hash_datagram_iter - Copy datagram to an iovec iterator
* and update a hash.
@@ -511,6 +512,7 @@ int skb_copy_and_hash_datagram_iter(const struct sk_buff *skb, int offset,
hash_and_copy_to_iter, hash);
}
EXPORT_SYMBOL(skb_copy_and_hash_datagram_iter);
+#endif

static size_t simple_copy_to_iter(const void *addr, size_t bytes,
void *data __always_unused, struct iov_iter *i)
--
2.7.4