Skip to contentSkip to conversation

don't memset null pointer

Drbd-dev Stanislaw Gruszka 2 participants 2 messages Nov 5, 2007 DRBD driver

lore
Share & tools
lore
#0 lore raw

Hi, this is trivial fix for memset null pointer:

drbd/lru_cache.c +1 -1
index a3171b6..37ab276 100644
@@ -57,8 +57,8 @@ struct lru_cache *lc_alloc(const char *name, unsigned int e_count,
 	bytes *= e_count;
 	bytes += sizeof(struct lru_cache);
 	lc     = vmalloc(bytes);
-	memset(lc, 0, bytes);
 	if (lc) {
+		memset(lc, 0, bytes);
 		INIT_LIST_HEAD(&lc->in_use);
 		INIT_LIST_HEAD(&lc->lru);
 		INIT_LIST_HEAD(&lc->free);
maintainer
#1 lore raw
Quoted 7 lines · On Monday 05 November 2007 13:04:49 Stanislaw Gruszka wrote:

Hi, this is trivial fix for memset null pointer:

drbd/lru_cache.c +0 -0
index a3171b6..37ab276 100644

drbd/lru_cache.c struct lru_cache *lc_alloc(const char *name, unsigned int · line 64

Quoted 9 lines
drbd/lru_cache.c +1 -1
@@ -57,8 +57,8 @@ struct lru_cache *lc_alloc(const char *name, unsigned int
 e_count, bytes *= e_count;
 	bytes += sizeof(struct lru_cache);
 	lc     = vmalloc(bytes);
-	memset(lc, 0, bytes);
 	if (lc) {
+		memset(lc, 0, bytes);
 		INIT_LIST_HEAD(&lc->in_use);
 		INIT_LIST_HEAD(&lc->lru);
 		INIT_LIST_HEAD(&lc->free);

Thanks!

-Phil

Signature · 3 lines
: Dipl-Ing Philipp Reisner                      Tel +43-1-8178292-50 :
: LINBIT Information Technologies GmbH          Fax +43-1-8178292-82 :
: Vivenotgasse 48, 1120 Vienna, Austria        http://www.linbit.com :