[PATCH] libkmod/hash: check for NULL before freeing hash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
fixes a crash on kmod-depmod -A when there's nothing to update.

 libkmod/libkmod-hash.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libkmod/libkmod-hash.c b/libkmod/libkmod-hash.c
index 8ca9cf4..11dac66 100644
--- a/libkmod/libkmod-hash.c
+++ b/libkmod/libkmod-hash.c
@@ -64,6 +64,10 @@ struct hash *hash_new(unsigned int n_buckets,
 void hash_free(struct hash *hash)
 {
 	struct hash_bucket *bucket, *bucket_end;
+
+	if (hash == NULL)
+		return;
+
 	bucket = hash->buckets;
 	bucket_end = bucket + hash->n_buckets;
 	for (; bucket < bucket_end; bucket++) {
-- 
1.7.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux