Blame SOURCES/nvme-ioctl-fix-double-free-in-a-loop-of-get-property-patch

44bbf1
commit d16e1d2784a48c9b25e58a0e821c737670c6cdc8
44bbf1
Author: Minwoo Im <minwoo.im@samsung.com>
44bbf1
Date:   Wed Apr 24 01:46:29 2019 +0100
44bbf1
44bbf1
    ioctl: Fix double-free in a loop of get_property
44bbf1
    
44bbf1
    As it was reported, *pbar could be double-freed in case
44bbf1
    get_property_helper() fails in the middle of the loop.
44bbf1
    
44bbf1
    This issue was reported by Ken Heitke on:
44bbf1
      https://github.com/linux-nvme/nvme-cli/pull/471
44bbf1
    
44bbf1
    Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
44bbf1
44bbf1
diff --git a/nvme-ioctl.c b/nvme-ioctl.c
44bbf1
index 4cf7aeb..16fdc66 100644
44bbf1
--- a/nvme-ioctl.c
44bbf1
+++ b/nvme-ioctl.c
44bbf1
@@ -626,8 +626,10 @@ int nvme_get_properties(int fd, void **pbar)
44bbf1
 		err = get_property_helper(fd, offset, *pbar + offset, &advance);
44bbf1
 		if (!err)
44bbf1
 			ret = 0;
44bbf1
-		else
44bbf1
+		else {
44bbf1
 			free(*pbar);
44bbf1
+			break;
44bbf1
+		}
44bbf1
 	}
44bbf1
 
44bbf1
 	return ret;