[sheepdog] [PATCH stable-0.7 1/3] farm: fix possible null defererence

Hitoshi Mitake mitake.hitoshi at gmail.com
Mon Oct 7 16:48:09 CEST 2013


From: Liu Yuan <namei.unix at gmail.com>

if trunk_file_read() return NULL, we should return immediately.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 dog/farm/trunk.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dog/farm/trunk.c b/dog/farm/trunk.c
index 91f293e..0515560 100644
--- a/dog/farm/trunk.c
+++ b/dog/farm/trunk.c
@@ -61,8 +61,10 @@ int for_each_entry_in_trunk(unsigned char *trunk_sha1,
 	int ret = -1;
 
 	trunk = trunk_file_read(trunk_sha1);
-	if (!trunk)
-		goto out;
+	if (!trunk) {
+		sd_err("failed to read trunk");
+		return ret;
+	}
 
 	total_count = trunk->nr_entries;
 	entry = trunk->entries;
-- 
1.8.1.2




More information about the sheepdog mailing list