Skip to contentSkip to conversation

ctl: should return NULL when dmsetup fail in find_dm_name

PATCH In review fanchaoting 2 participants 3 messages Mar 11, 2013 – Mar 25, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ctl: should return NULL when dmsetup fail in find_dm_name

when dmsetup fail in find_dm_name, it should return NULL,if don't do it. it will cause core dump in get_dm when do free(name).

---
 ctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ctl.c +1 -1
index 2071b0e..0ac1c44 100644
@@ -489,7 +489,7 @@ find_dm_name(int major, int minor)
        if (((fd = get_output("/sbin/dmsetup", argv)) == -1) ||
            ((fp = fdopen(fd, "r")) == NULL)) {
                printf("%s: get_output/fdopen failed\n", __func__);
-               return;
+               return NULL;
        }
        while (fgets(buf, sizeof (buf), fp) != NULL) {
                t = __token_init(buf, '\t');

--
1.7.1

#1 lore raw
Quoted 2 lines · fanchaoting

when dmsetup fail in find_dm_name, it should return NULL,if don't do it. it will cause core dump in get_dm when do free(name).

Thanks, but what version are you using?
This was already fixed here:
http://git.linux-nfs.org/?p=bhalevy/pnfsd-block-ctl.git;a=commitdiff;h=9082efe1dc12248e530d4200d7150a286abea922

Please update to the latest version
git://linux-nfs.org/~bhalevy/pnfsd-block-ctl.git

Benny

Quoted 28 lines
---
 ctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ctl.c +1 -2
index 2071b0e..0ac1c44 100644
@@ -489,7 +489,7 @@ find_dm_name(int major, int minor)
        if (((fd = get_output("/sbin/dmsetup", argv)) == -1) ||
            ((fp = fdopen(fd, "r")) == NULL)) {
                printf("%s: get_output/fdopen failed\n", __func__);
-               return;
+               return NULL;
        }
        while (fgets(buf, sizeof (buf), fp) != NULL) {
                t = __token_init(buf, '\t');
--

1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 11 lines · Benny Halevy
Quoted 2 lines · fanchaoting

when dmsetup fail in find_dm_name, it should return NULL,if don't do it. it will cause core dump in get_dm when do free(name).

Thanks, but what version are you using?
This was already fixed here:
http://git.linux-nfs.org/?p=bhalevy/pnfsd-block-ctl.git;a=commitdiff;h=9082efe1dc12248e530d4200d7150a286abea922

Please update to the latest version
git://linux-nfs.org/~bhalevy/pnfsd-block-ctl.git

thanks for telling me .

Quoted 35 lines

Benny

Quoted 22 lines
---
 ctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ctl.c +1 -2
index 2071b0e..0ac1c44 100644
@@ -489,7 +489,7 @@ find_dm_name(int major, int minor)
        if (((fd = get_output("/sbin/dmsetup", argv)) == -1) ||
            ((fp = fdopen(fd, "r")) == NULL)) {
                printf("%s: get_output/fdopen failed\n", __func__);
-               return;
+               return NULL;
        }
        while (fgets(buf, sizeof (buf), fp) != NULL) {
                t = __token_init(buf, '\t');
--

1.7.1

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html