From 78f33946f1f635cb630051c6c838418354a34b51 Mon Sep 17 00:00:00 2001 From: lixiaokeng Date: Mon, 9 Nov 2020 09:45:42 +0800 Subject: [PATCH] lib: fix potential segfault in LUKS2_token_buffer_free The value of h may be NULL. Check it vefore visiting its memeber to avoid segfault. Signed-off-by: Lixiaokeng Signed-off-by: Linfeilong --- lib/luks2/luks2_token.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/luks2/luks2_token.c b/lib/luks2/luks2_token.c index ad6722a3..c8be1c14 100644 --- a/lib/luks2/luks2_token.c +++ b/lib/luks2/luks2_token.c @@ -329,7 +329,7 @@ static void LUKS2_token_buffer_free(struct crypt_device *cd, { const crypt_token_handler *h = LUKS2_token_handler(cd, token); - if (h->buffer_free) + if (h && h->buffer_free) h->buffer_free(buffer, buffer_len); else { crypt_safe_memzero(buffer, buffer_len);