Skip to contentSkip to conversation

PM: hibernate: Drop NULL pointer checks before acomp_request_free()

PATCH In review Rafael J. Wysocki 2 participants 2 messages Jan 26 – Jan 27

Subsystems (2)
lore
Share & tools
lore

Rafael J. Wysocki

author maintainer
#0 lore raw

PATCH 1/1 PM: hibernate: Drop NULL pointer checks before acomp_request_free()

From: Rafael J. Wysocki <[email protected]>

Since acomp_request_free() checks its argument against NULL, the NULL pointer checks before calling it added by commit ("7966cf0ebe32 PM:
hibernate: Fix crash when freeing invalid crypto compressor") are redundant, so drop them.

No intentional functional impact.

---
 kernel/power/swap.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/power/swap.c +4 -4
@@ -902,8 +902,8 @@ out_clean:
 		for (thr = 0; thr < nr_threads; thr++) {
 			if (data[thr].thr)
 				kthread_stop(data[thr].thr);
-			if (data[thr].cr)
-				acomp_request_free(data[thr].cr);
+
+			acomp_request_free(data[thr].cr);
 
 			if (!IS_ERR_OR_NULL(data[thr].cc))
 				crypto_free_acomp(data[thr].cc);
@@ -1502,8 +1502,8 @@ out_clean:
 		for (thr = 0; thr < nr_threads; thr++) {
 			if (data[thr].thr)
 				kthread_stop(data[thr].thr);
-			if (data[thr].cr)
-				acomp_request_free(data[thr].cr);
+
+			acomp_request_free(data[thr].cr);
 
 			if (!IS_ERR_OR_NULL(data[thr].cc))
 				crypto_free_acomp(data[thr].cc);
#1 lore raw
Quoted 32 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Since acomp_request_free() checks its argument against NULL, the NULL pointer checks before calling it added by commit ("7966cf0ebe32 PM:
hibernate: Fix crash when freeing invalid crypto compressor") are redundant, so drop them.

No intentional functional impact.

---
 kernel/power/swap.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/power/swap.c +2 -2
@@ -902,8 +902,8 @@ out_clean:
                for (thr = 0; thr < nr_threads; thr++) {
                        if (data[thr].thr)
                                kthread_stop(data[thr].thr);
-                       if (data[thr].cr)
-                               acomp_request_free(data[thr].cr);
+
+                       acomp_request_free(data[thr].cr);
 
                        if (!IS_ERR_OR_NULL(data[thr].cc))
                                crypto_free_acomp(data[thr].cc);

kernel/power/swap.c out_clean: · line 1509

Quoted 10 lines
kernel/power/swap.c +2 -2
@@ -1502,8 +1502,8 @@ out_clean:
                for (thr = 0; thr < nr_threads; thr++) {
                        if (data[thr].thr)
                                kthread_stop(data[thr].thr);
-                       if (data[thr].cr)
-                               acomp_request_free(data[thr].cr);
+
+                       acomp_request_free(data[thr].cr);
 
                        if (!IS_ERR_OR_NULL(data[thr].cc))
                                crypto_free_acomp(data[thr].cc);

Thanks, this makes sense to me. Dropping the redundant NULL checks looks correct.