* [PATCH v2] crypto: af_alg - check possible NULL pointer
@ 2021-12-31 1:40 Jiasheng Jiang
2022-01-07 3:34 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2021-12-31 1:40 UTC (permalink / raw)
To: ebiggers, herbert, davem; +Cc: linux-crypto, linux-kernel, Jiasheng Jiang
Because of the possible alloc failure of the alloc_page(), it could
return NULL pointer.
And there is a check below the sg_assign_page().
But it will be more logical to move the NULL check before the
sg_assign_page().
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
Changelog:
v1 -> v2
* Change 1. Move the previous check in front of sg_assign_page().
---
crypto/af_alg.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 18cc82dc4a42..f79e446d8132 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -931,16 +931,19 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
sg_unmark_end(sg + sgl->cur - 1);
do {
+ struct page *pg;
unsigned int i = sgl->cur;
plen = min_t(size_t, len, PAGE_SIZE);
- sg_assign_page(sg + i, alloc_page(GFP_KERNEL));
- if (!sg_page(sg + i)) {
+ pg = alloc_page(GFP_KERNEL);
+ if (!pg) {
err = -ENOMEM;
goto unlock;
}
+ sg_assign_page(sg + i, pg);
+
err = memcpy_from_msg(page_address(sg_page(sg + i)),
msg, plen);
if (err) {
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] crypto: af_alg - check possible NULL pointer
2021-12-31 1:40 [PATCH v2] crypto: af_alg - check possible NULL pointer Jiasheng Jiang
@ 2022-01-07 3:34 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2022-01-07 3:34 UTC (permalink / raw)
To: Jiasheng Jiang; +Cc: ebiggers, davem, linux-crypto, linux-kernel
On Fri, Dec 31, 2021 at 09:40:36AM +0800, Jiasheng Jiang wrote:
> Because of the possible alloc failure of the alloc_page(), it could
> return NULL pointer.
> And there is a check below the sg_assign_page().
> But it will be more logical to move the NULL check before the
> sg_assign_page().
>
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> Changelog:
>
> v1 -> v2
>
> * Change 1. Move the previous check in front of sg_assign_page().
> ---
> crypto/af_alg.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
Patch applied with modified Subject line. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-07 3:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-31 1:40 [PATCH v2] crypto: af_alg - check possible NULL pointer Jiasheng Jiang
2022-01-07 3:34 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).