Skip to content

Commit 1f9d0b1

Browse files
committed
linuxkm/: fix error checking on malloc()ed values (! ptr, not IS_ERR(ptr)).
1 parent d4fc8c3 commit 1f9d0b1

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

linuxkm/lkcapi_aes_glue.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,34 +2767,30 @@ static int linuxkm_test_aesgcm(void)
27672767

27682768
/* now the kernel crypto part */
27692769
assoc2 = malloc(sizeof(assoc));
2770-
if (IS_ERR(assoc2)) {
2770+
if (! assoc2) {
27712771
pr_err("error: malloc failed\n");
2772-
assoc2 = NULL;
27732772
goto test_gcm_end;
27742773
}
27752774
memset(assoc2, 0, sizeof(assoc));
27762775
memcpy(assoc2, assoc, sizeof(assoc));
27772776

27782777
iv = malloc(WC_AES_BLOCK_SIZE);
2779-
if (IS_ERR(iv)) {
2778+
if (! iv) {
27802779
pr_err("error: malloc failed\n");
2781-
iv = NULL;
27822780
goto test_gcm_end;
27832781
}
27842782
memset(iv, 0, WC_AES_BLOCK_SIZE);
27852783
memcpy(iv, ivstr, GCM_NONCE_MID_SZ);
27862784

27872785
enc2 = malloc(decryptLen);
2788-
if (IS_ERR(enc2)) {
2786+
if (! enc2) {
27892787
pr_err("error: malloc failed\n");
2790-
enc2 = NULL;
27912788
goto test_gcm_end;
27922789
}
27932790

27942791
dec2 = malloc(decryptLen);
2795-
if (IS_ERR(dec2)) {
2792+
if (! dec2) {
27962793
pr_err("error: malloc failed\n");
2797-
dec2 = NULL;
27982794
goto test_gcm_end;
27992795
}
28002796

@@ -2836,19 +2832,17 @@ static int linuxkm_test_aesgcm(void)
28362832

28372833
src = malloc(sizeof(struct scatterlist) * 2);
28382834

2839-
if (IS_ERR(src)) {
2835+
if (! src) {
28402836
pr_err("error: malloc src failed: %ld\n",
28412837
PTR_ERR(src));
2842-
src = NULL;
28432838
goto test_gcm_end;
28442839
}
28452840

28462841
dst = malloc(sizeof(struct scatterlist) * 2);
28472842

2848-
if (IS_ERR(dst)) {
2843+
if (! dst) {
28492844
pr_err("error: malloc dst failed: %ld\n",
28502845
PTR_ERR(dst));
2851-
dst = NULL;
28522846
goto test_gcm_end;
28532847
}
28542848

0 commit comments

Comments
 (0)