If calloc() returns NULL just return ENOMEM; if strdup() returns NULL we should free dev and return errno.
Signed-off-by: Wenchao Hao <haowenc...@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqian...@huawei.com> --- utils/fwparam_ibft/fwparam_ppc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/fwparam_ibft/fwparam_ppc.c b/utils/fwparam_ibft/fwparam_ppc.c index 429d45c..b5eaa00 100644 --- a/utils/fwparam_ibft/fwparam_ppc.c +++ b/utils/fwparam_ibft/fwparam_ppc.c @@ -332,9 +332,16 @@ static int find_initiator(const char *fpath, const struct stat *sb, int tflag, "/aliases/iscsi-disk"))) { if (dev_count < OFWDEV_MAX) { - ofwdevs[dev_count++] = dev = - calloc(sizeof(struct ofw_dev), 1); + dev = calloc(sizeof(struct ofw_dev), 1); + if (!dev) + return -ENOMEM; + dev->prop_path = strdup(fpath + devtree_offset); + if (!dev->prop_path) { + free(dev); + return errno; + } + ofwdevs[dev_count++] = dev; } } return 0; -- 2.27.0 -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/open-iscsi/20201207015410.48488-5-haowenchao%40huawei.com.