Check if calloc() failed and return an error rather than dereferencing
the NULL pointer. Found by static analysis.
Test-Parameters: trivial
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Ie4a5e3341fab1de77990fc99df54cdc562dcab07
Reviewed-on: https://review.whamcloud.com/31400
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
int rc = 0;
options = calloc(strlen(orig_options) + 1, 1);
+ if (options == NULL)
+ return ENOMEM;
+
*flagp = 0;
nextopt = orig_options;
while ((opt = strsep(&nextopt, ","))) {
/* empty option */
continue;
- /* Handle retries in a slightly different
- * manner */
+ /* Handle retries in a slightly different manner */
arg = opt;
val = strchr(opt, '=');
/* please note that some ldiskfs mount options are also in
"%s: shared key path too long\n",
progname);
free(options);
- return -1;
+ return EINVAL;
}
strncpy(mop->mo_skpath, val + 1, strlen(val + 1));
#endif
if (rc) {
fprintf(stderr, "%s: can't parse options: %s\n",
progname, options);
- rc = EINVAL;
goto out_options;
}