return 0;
failed:
- if (net->ibn_dev == NULL && ibdev != NULL)
+ if (net != NULL && net->ibn_dev == NULL && ibdev != NULL)
kiblnd_destroy_dev(ibdev);
kiblnd_shutdown(ni);
{
unsigned int nob = 0;
+ LASSERT(niov == 0 || iov != NULL);
while (niov-- > 0)
nob += (iov++)->iov_len;
{
unsigned int nob = 0;
+ LASSERT(niov == 0 || kiov != NULL);
while (niov-- > 0)
nob += (kiov++)->kiov_len;
lst_stat_query_ioctl(lstio_stat_args_t *args)
{
int rc;
- char *name;
+ char *name = NULL;
/* TODO: not finished */
if (args->lstio_sta_key != console_session.ses_key)
return -EACCES;
- if (args->lstio_sta_resultp == NULL ||
- (args->lstio_sta_namep == NULL &&
- args->lstio_sta_idsp == NULL) ||
- args->lstio_sta_nmlen <= 0 ||
- args->lstio_sta_nmlen > LST_NAME_SIZE)
- return -EINVAL;
-
- if (args->lstio_sta_idsp != NULL &&
- args->lstio_sta_count <= 0)
- return -EINVAL;
-
- LIBCFS_ALLOC(name, args->lstio_sta_nmlen + 1);
- if (name == NULL)
- return -ENOMEM;
+ if (args->lstio_sta_resultp == NULL)
+ return -EINVAL;
- if (copy_from_user(name, args->lstio_sta_namep,
- args->lstio_sta_nmlen)) {
- LIBCFS_FREE(name, args->lstio_sta_nmlen + 1);
- return -EFAULT;
- }
+ if (args->lstio_sta_idsp != NULL) {
+ if (args->lstio_sta_count <= 0)
+ return -EINVAL;
- if (args->lstio_sta_idsp == NULL) {
- rc = lstcon_group_stat(name, args->lstio_sta_timeout,
- args->lstio_sta_resultp);
- } else {
- rc = lstcon_nodes_stat(args->lstio_sta_count,
+ rc = lstcon_nodes_stat(args->lstio_sta_count,
args->lstio_sta_idsp,
args->lstio_sta_timeout,
args->lstio_sta_resultp);
- }
+ } else if (args->lstio_sta_namep != NULL) {
+ if (args->lstio_sta_nmlen <= 0 ||
+ args->lstio_sta_nmlen > LST_NAME_SIZE)
+ return -EINVAL;
- LIBCFS_FREE(name, args->lstio_sta_nmlen + 1);
+ LIBCFS_ALLOC(name, args->lstio_sta_nmlen + 1);
+ if (name == NULL)
+ return -ENOMEM;
- return rc;
+ rc = copy_from_user(name, args->lstio_sta_namep,
+ args->lstio_sta_nmlen);
+ if (rc == 0)
+ rc = lstcon_group_stat(name, args->lstio_sta_timeout,
+ args->lstio_sta_resultp);
+ else
+ rc = -EFAULT;
+
+ } else {
+ rc = -EINVAL;
+ }
+
+ if (name != NULL)
+ LIBCFS_FREE(name, args->lstio_sta_nmlen + 1);
+ return rc;
}
int lst_test_add_ioctl(lstio_test_args_t *args)
iops = &obj->do_index_ops->dio_it;
LASSERT(iops != NULL);
- LASSERT(obj != NULL);
LASSERT(param->fsp_it != NULL);
iops->fini(¶m->fsp_env, param->fsp_it);
lu_env_fini(¶m->fsp_env);
/* For printf's only, make sure uuid is terminated */
static inline char *obd_uuid2str(const struct obd_uuid *uuid)
{
+ if (uuid == NULL)
+ return NULL;
+
if (uuid->uuid[sizeof(*uuid) - 1] != '\0') {
/* Obviously not safe, but for printfs, no real harm done...
we're always null-terminated, even in a race. */
lock->l_policy_data = *policy;
if (client_cookie != NULL)
lock->l_client_cookie = *client_cookie;
- if (type == LDLM_EXTENT)
- lock->l_req_extent = policy->l_extent;
+ if (type == LDLM_EXTENT) {
+ /* extent lock without policy is a bug */
+ if (policy == NULL)
+ LBUG();
+
+ lock->l_req_extent = policy->l_extent;
+ }
err = ldlm_lock_enqueue(ns, &lock, policy, flags);
if (unlikely(err != ELDLM_OK))
lock->l_policy_data = *policy;
}
- if (einfo->ei_type == LDLM_EXTENT)
- lock->l_req_extent = policy->l_extent;
+ if (einfo->ei_type == LDLM_EXTENT) {
+ /* extent lock without policy is a bug */
+ if (policy == NULL)
+ LBUG();
+
+ lock->l_req_extent = policy->l_extent;
+ }
LDLM_DEBUG(lock, "client-side enqueue START, flags %llx\n",
*flags);
}
* and MDC stuff will be called directly, for instance while reading
* ../mdc/../kbytesfree procfs file, etc.
*/
- if (data->ocd_connect_flags & OBD_CONNECT_REAL)
+ if (data != NULL && (data->ocd_connect_flags & OBD_CONNECT_REAL))
rc = lmv_check_connect(obd);
#ifdef __KERNEL__
l->ldo_def_stripe_size = 0;
l->ldo_def_stripenr = 0;
- LASSERT(buf);
- LASSERT(buf->lb_buf);
+ LASSERT(buf != NULL && buf->lb_buf != NULL);
lum = buf->lb_buf;
rc = lod_verify_striping(d, buf, 0);
cfs_time_seconds(1), NULL, NULL);
rc = l_wait_event(waitq, lov_check_set(lov, ost_idx), &lwi);
- if (tgt != NULL && tgt->ltd_active)
+ if (tgt->ltd_active)
return 1;
return 0;
rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
/* XXX do something about time, uid, gid */
- rec->cr_opcode = REINT_OPEN;
- rec->cr_fsuid = current_fsuid();
- rec->cr_fsgid = current_fsgid();
- rec->cr_cap = cfs_curproc_cap_pack();
+ rec->cr_opcode = REINT_OPEN;
+ rec->cr_fsuid = current_fsuid();
+ rec->cr_fsgid = current_fsgid();
+ rec->cr_cap = cfs_curproc_cap_pack();
+ rec->cr_mode = mode;
+ cr_flags = mds_pack_open_flags(flags, mode);
+ rec->cr_rdev = rdev;
+ rec->cr_umask = current_umask();
if (op_data != NULL) {
- rec->cr_fid1 = op_data->op_fid1;
+ rec->cr_fid1 = op_data->op_fid1;
+ rec->cr_fid2 = op_data->op_fid2;
+ rec->cr_time = op_data->op_mod_time;
+ rec->cr_suppgid1 = op_data->op_suppgids[0];
+ rec->cr_suppgid2 = op_data->op_suppgids[1];
+ rec->cr_bias = op_data->op_bias;
+ rec->cr_old_handle = op_data->op_handle;
+
+ mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
+ /* the next buffer is child capa, which is used for replay,
+ * will be packed from the data in reply message. */
+
+ if (op_data->op_name) {
+ tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
+ LOGL0(op_data->op_name, op_data->op_namelen, tmp);
+ if (op_data->op_bias & MDS_CREATE_VOLATILE)
+ cr_flags |= MDS_OPEN_VOLATILE;
+ }
+#ifndef __KERNEL__
+ /*XXX a hack for liblustre to set EA (LL_IOC_LOV_SETSTRIPE) */
rec->cr_fid2 = op_data->op_fid2;
- }
- rec->cr_mode = mode;
- cr_flags = mds_pack_open_flags(flags, mode);
- rec->cr_rdev = rdev;
- rec->cr_time = op_data->op_mod_time;
- rec->cr_suppgid1 = op_data->op_suppgids[0];
- rec->cr_suppgid2 = op_data->op_suppgids[1];
- rec->cr_bias = op_data->op_bias;
- rec->cr_umask = current_umask();
- rec->cr_old_handle = op_data->op_handle;
-
- mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
- /* the next buffer is child capa, which is used for replay,
- * will be packed from the data in reply message. */
-
- if (op_data->op_name) {
- tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
- LOGL0(op_data->op_name, op_data->op_namelen, tmp);
- if (op_data->op_bias & MDS_CREATE_VOLATILE)
- cr_flags |= MDS_OPEN_VOLATILE;
+#endif
}
if (lmm) {
cr_flags |= MDS_OPEN_HAS_EA;
-#ifndef __KERNEL__
- /*XXX a hack for liblustre to set EA (LL_IOC_LOV_SETSTRIPE) */
- rec->cr_fid2 = op_data->op_fid2;
-#endif
tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
memcpy(tmp, lmm, lmmlen);
}
if (info)
mdt_body_reverse_idmap(info, b);
- if (b->valid & OBD_MD_FLSIZE)
+ if (fid != NULL && (b->valid & OBD_MD_FLSIZE))
CDEBUG(D_VFSTRACE, DFID": returning size %llu\n",
PFID(fid), (unsigned long long)b->size);
}
RETURN(mdt_ioepoch_close_on_eviction(info, o));
if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)
RETURN(mdt_ioepoch_close_on_replay(info, o));
- if (info->mti_ioepoch->flags & MF_EPOCH_CLOSE)
+ if (info->mti_ioepoch && (info->mti_ioepoch->flags & MF_EPOCH_CLOSE))
RETURN(mdt_ioepoch_close_reg(info, o));
/* IO epoch is not closed. */
RETURN(MDT_IOEPOCH_OPENED);
ioepoch = info->mti_ioepoch ?
info->mti_ioepoch->ioepoch : o->mot_ioepoch;
- if (!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY))
+ if (req != NULL
+ && !(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY))
rc = mdt_som_attr_set(info, o, ioepoch, act);
mdt_object_som_enable(o, ioepoch);
}
LASSERT(lsi->lsi_lmd);
if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR)) {
struct config_llog_data *recover_cld;
- *strrchr(seclogname, '-') = 0;
+ ptr = strrchr(seclogname, '-');
+ if (ptr != NULL) {
+ *ptr = 0;
+ }
+ else {
+ CERROR("sptlrpc log name not correct: %s", seclogname);
+ config_log_put(cld);
+ RETURN(-EINVAL);
+ }
recover_cld = config_recover_log_add(obd, seclogname, cfg, sb);
if (IS_ERR(recover_cld))
GOTO(out_err3, rc = PTR_ERR(recover_cld));
}
units = 1;
- switch(*end) {
- case 'p': case 'P':
- units <<= 10;
- case 't': case 'T':
- units <<= 10;
- case 'g': case 'G':
- units <<= 10;
- case 'm': case 'M':
- units <<= 10;
- case 'k': case 'K':
- units <<= 10;
- }
+ if (end != NULL) {
+ switch (*end) {
+ case 'p': case 'P':
+ units <<= 10;
+ case 't': case 'T':
+ units <<= 10;
+ case 'g': case 'G':
+ units <<= 10;
+ case 'm': case 'M':
+ units <<= 10;
+ case 'k': case 'K':
+ units <<= 10;
+ }
+ }
/* Specified units override the multiplier */
if (units)
mult = mult < 0 ? -units : units;
int count, int *eof, void *data)
{
struct obd_device *obd = (struct obd_device *)data;
- struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+ struct ofd_device *ofd;
LASSERT(obd != NULL);
+ ofd = ofd_dev(obd->obd_lu_dev);
*eof = 1;
return snprintf(page, count, "%d\n", ofd->ofd_precreate_batch);
}
}
CDEBUG(D_HA, "%s: get connection from MDS %d\n", obd->obd_name,
- data->ocd_group);
+ data ? data->ocd_group : -1);
out:
if (rc != 0) {
static inline int __osd_xattr_get(struct inode *inode, struct dentry *dentry,
const char *name, void *buf, int len)
{
+ if (inode == NULL)
+ return -EINVAL;
+
dentry->d_inode = inode;
dentry->d_sb = inode->i_sb;
return inode->i_op->getxattr(dentry, name, buf, len);
scrub->os_pos_current = param->gbase + ++(param->offset);
wait:
- if (it != NULL && it->ooi_waiting &&
+ if (it != NULL && it->ooi_waiting && ooc != NULL &&
ooc->ooc_pos_preload < scrub->os_pos_current) {
spin_lock(&scrub->os_lock);
it->ooi_waiting = 0;
struct obd_device *dev = data;
struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+ if (osp == NULL)
+ return -EINVAL;
+
/*
* This counter used to determine if OST has space returned.
* Now we need to wait for the following:
struct llog_ctxt *ctxt;
ctxt = llog_get_context(d->opd_obd, LLOG_MDS_OST_ORIG_CTXT);
- llog_cat_close(env, ctxt->loc_handle);
+ if (ctxt != NULL)
+ llog_cat_close(env, ctxt->loc_handle);
llog_cleanup(env, ctxt);
}
return;
swabber(value);
ptlrpc_buf_set_swabbed(pill->rc_req, inout, offset);
- if (dump) {
+ if (dump && field->rmf_dumper) {
CDEBUG(D_RPCTRACE, "Dump of swabbed field %s "
"follows\n", field->rmf_name);
field->rmf_dumper(value);
mutex_lock(&sptlrpc_conf_lock);
conf = sptlrpc_conf_get(fsname, 0);
- if (conf && conf->sc_local) {
- LASSERT(conf->sc_updated == 0);
- sptlrpc_conf_free_rsets(conf);
- }
- conf->sc_modified = 0;
+ if (conf) {
+ if (conf->sc_local) {
+ LASSERT(conf->sc_updated == 0);
+ sptlrpc_conf_free_rsets(conf);
+ }
+ conf->sc_modified = 0;
+ }
mutex_unlock(&sptlrpc_conf_lock);
}
continue;
strcpy(dev, tmp);
tmp = strchr(dev, ' ');
- *tmp = '\0';
+ if (tmp != NULL)
+ *tmp = '\0';
break;
}
}
if (ostname != NULL)
len = strlen(ostname);
- if (poolname == NULL)
- rc = find_target_obdpath(fsname, buffer);
- else
+ if (poolname == NULL) {
+ if (len == 0)
+ rc = -EINVAL;
+ else
+ rc = find_target_obdpath(fsname, buffer);
+ } else {
rc = find_poolpath(fsname, poolname, buffer);
+ }
if (rc)
return rc;
NI_NAMEREQD | NI_NOFQDN) == 0) {
if ((p = strchr(name, '.')))
*p = '\0';
- len = strlen(name) + strlen(lnet) + 2;
+ len = strlen(name) + 2;
+ if (lnet)
+ len += strlen(lnet);
if (!(res = malloc(len)))
nl_oom();
snprintf(res, len, "%s@%s", name, lnet);
FILE *fp;
int found = 0;
char buf[1024];
+ char *ptr;
fp = fopen("/proc/modules", "r");
if (fp == NULL)
return -1;
while (fgets(buf, 1024, fp) != NULL) {
- *strchr(buf, ' ') = 0;
+ ptr = strchr(buf, ' ');
+ if (ptr != NULL)
+ *ptr = 0;
if (strcmp(module, buf) == 0) {
found = 1;
break;