Message ID | 1476410880-7156-1-git-send-email-huang.wei56@zte.com.cn (mailing list archive) |
---|---|
State | Not Applicable, archived |
Delegated to: | Mike Snitzer |
Headers | show |
On 10/13/2016 07:08 PM, huang.wei56@zte.com.cn wrote: > From: "wei.huang" <huang.wei56@zte.com.cn> > > Problem: > when we configure device like vendor is COMPELNT in multipath.conf, multipathd will be coredump. > > Reasons: > some vonders are not configured features in default_hw. In add_feature, strstr's first parameter *f maybe null. > > Signed-off-by: wei.huang <huang.wei56@zte.com.cn> > --- > libmultipath/structs.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/libmultipath/structs.c b/libmultipath/structs.c > index fee58e5..41e142f 100644 > --- a/libmultipath/structs.c > +++ b/libmultipath/structs.c > @@ -520,6 +520,20 @@ add_feature (char **f, char *n) > if (!n || *n == '0') > return 0; > > + /* default feature is null */ > + if(!*f) > + { > + l = strlen("1 ") + strlen(n) + 1; > + t = MALLOC(l); > + if (!t) > + return 1; > + > + snprintf(t, l, "1 %s", n); > + *f = t; > + > + return 0; > + } > + > /* Check if feature is already present */ > if (strstr(*f, n)) > return 0; > Hello Wei Huang, Please use asprintf() instead of open coding it and please also make the title of your patch comprehensible. Your patch avoids that multipathd triggers a core dump for a certain vendor name but that's not clear from the "add_feature: coredump". Thanks, Bart. -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
Hi Bart, Thanks for your answer. I commit the code again with the title "segment faulty occured in add_feature()", please review. Thanks, Wei huang. Bart Van Assche <bart.vanassche@sandisk.com> 2016-10-28 23:14 收件人 <huang.wei56@zte.com.cn>, Christophe Varoqui <christophe.varoqui@opensvc.com>, 抄送 <tang.junhui@zte.com.cn>, <zhang.kai16@zte.com.cn>, <dm-devel@redhat.com> 主题 Re: [dm-devel] [PATCH] add_feature: coredump On 10/13/2016 07:08 PM, huang.wei56@zte.com.cn wrote: > From: "wei.huang" <huang.wei56@zte.com.cn> > > Problem: > when we configure device like vendor is COMPELNT in multipath.conf, multipathd will be coredump. > > Reasons: > some vonders are not configured features in default_hw. In add_feature, strstr's first parameter *f maybe null. > > Signed-off-by: wei.huang <huang.wei56@zte.com.cn> > --- > libmultipath/structs.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/libmultipath/structs.c b/libmultipath/structs.c > index fee58e5..41e142f 100644 > --- a/libmultipath/structs.c > +++ b/libmultipath/structs.c > @@ -520,6 +520,20 @@ add_feature (char **f, char *n) > if (!n || *n == '0') > return 0; > > + /* default feature is null */ > + if(!*f) > + { > + l = strlen("1 ") + strlen(n) + 1; > + t = MALLOC(l); > + if (!t) > + return 1; > + > + snprintf(t, l, "1 %s", n); > + *f = t; > + > + return 0; > + } > + > /* Check if feature is already present */ > if (strstr(*f, n)) > return 0; > Hello Wei Huang, Please use asprintf() instead of open coding it and please also make the title of your patch comprehensible. Your patch avoids that multipathd triggers a core dump for a certain vendor name but that's not clear from the "add_feature: coredump". Thanks, Bart. -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
diff --git a/libmultipath/structs.c b/libmultipath/structs.c index fee58e5..41e142f 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -520,6 +520,20 @@ add_feature (char **f, char *n) if (!n || *n == '0') return 0; + /* default feature is null */ + if(!*f) + { + l = strlen("1 ") + strlen(n) + 1; + t = MALLOC(l); + if (!t) + return 1; + + snprintf(t, l, "1 %s", n); + *f = t; + + return 0; + } + /* Check if feature is already present */ if (strstr(*f, n)) return 0;