Skip to content

Commit 755bddd

Browse files
Colin Ian Kingherbertx
authored andcommitted
crypto: marvell/octeontx - fix double free of ptr
Currently in the case where eq->src != req->ds, the allocation of ptr is kfree'd at the end of the code block. However later on in the case where enc is not null any of the error return paths that return via the error handling return path end up performing an erroneous second kfree of ptr. Fix this by adding an error exit label error_free and only jump to this when ptr needs kfree'ing thus avoiding the double free issue. Addresses-Coverity: ("Double free") Fixes: 10b4f09 ("crypto: marvell - add the Virtual Function driver for CPT") Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent b5f1303 commit 755bddd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/crypto/marvell/octeontx/otx_cptvf_algs.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,13 +1161,13 @@ static inline u32 create_aead_null_output_list(struct aead_request *req,
11611161
inputlen);
11621162
if (status != inputlen) {
11631163
status = -EINVAL;
1164-
goto error;
1164+
goto error_free;
11651165
}
11661166
status = sg_copy_from_buffer(req->dst, sg_nents(req->dst), ptr,
11671167
inputlen);
11681168
if (status != inputlen) {
11691169
status = -EINVAL;
1170-
goto error;
1170+
goto error_free;
11711171
}
11721172
kfree(ptr);
11731173
}
@@ -1209,8 +1209,10 @@ static inline u32 create_aead_null_output_list(struct aead_request *req,
12091209

12101210
req_info->outcnt = argcnt;
12111211
return 0;
1212-
error:
1212+
1213+
error_free:
12131214
kfree(ptr);
1215+
error:
12141216
return status;
12151217
}
12161218

0 commit comments

Comments
 (0)