... postponing assignments until they're needed. Doesn't change code size.
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
{
struct inode *inode;
struct ipc_namespace *ns = data;
{
struct inode *inode;
struct ipc_namespace *ns = data;
sb->s_blocksize = PAGE_CACHE_SIZE;
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
sb->s_blocksize = PAGE_CACHE_SIZE;
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
if (!sb->s_root) {
iput(inode);
error = -ENOMEM;
if (!sb->s_root) {
iput(inode);
error = -ENOMEM;
- ret = -EINVAL;
- if (!mq_attr_ok(ipc_ns, attr))
+ if (!mq_attr_ok(ipc_ns, attr)) {
+ ret = -EINVAL;
/* store for use during create */
dentry->d_fsdata = attr;
}
/* store for use during create */
dentry->d_fsdata = attr;
}
if (oflag & O_CREAT) {
if (dentry->d_inode) { /* entry already exists */
audit_inode(name, dentry);
if (oflag & O_CREAT) {
if (dentry->d_inode) { /* entry already exists */
audit_inode(name, dentry);
- error = -EEXIST;
- if (oflag & O_EXCL)
+ if (oflag & O_EXCL) {
+ error = -EEXIST;
filp = do_open(ipc_ns, dentry, oflag);
} else {
filp = do_create(ipc_ns, ipc_ns->mq_mnt->mnt_root,
filp = do_open(ipc_ns, dentry, oflag);
} else {
filp = do_create(ipc_ns, ipc_ns->mq_mnt->mnt_root,
u_attr ? &attr : NULL);
}
} else {
u_attr ? &attr : NULL);
}
} else {
- error = -ENOENT;
- if (!dentry->d_inode)
+ if (!dentry->d_inode) {
+ error = -ENOENT;
audit_inode(name, dentry);
filp = do_open(ipc_ns, dentry, oflag);
}
audit_inode(name, dentry);
filp = do_open(ipc_ns, dentry, oflag);
}
audit_mq_sendrecv(mqdes, msg_len, msg_prio, p);
timeout = prepare_timeout(p);
audit_mq_sendrecv(mqdes, msg_len, msg_prio, p);
timeout = prepare_timeout(p);
+ if (unlikely(!filp)) {
+ ret = -EBADF;
inode = filp->f_path.dentry->d_inode;
inode = filp->f_path.dentry->d_inode;
- if (unlikely(filp->f_op != &mqueue_file_operations))
+ if (unlikely(filp->f_op != &mqueue_file_operations)) {
+ ret = -EBADF;
info = MQUEUE_I(inode);
audit_inode(NULL, filp->f_path.dentry);
info = MQUEUE_I(inode);
audit_inode(NULL, filp->f_path.dentry);
- if (unlikely(!(filp->f_mode & FMODE_WRITE)))
+ if (unlikely(!(filp->f_mode & FMODE_WRITE))) {
+ ret = -EBADF;
if (unlikely(msg_len > info->attr.mq_msgsize)) {
ret = -EMSGSIZE;
if (unlikely(msg_len > info->attr.mq_msgsize)) {
ret = -EMSGSIZE;
audit_mq_sendrecv(mqdes, msg_len, 0, p);
timeout = prepare_timeout(p);
audit_mq_sendrecv(mqdes, msg_len, 0, p);
timeout = prepare_timeout(p);
+ if (unlikely(!filp)) {
+ ret = -EBADF;
inode = filp->f_path.dentry->d_inode;
inode = filp->f_path.dentry->d_inode;
- if (unlikely(filp->f_op != &mqueue_file_operations))
+ if (unlikely(filp->f_op != &mqueue_file_operations)) {
+ ret = -EBADF;
info = MQUEUE_I(inode);
audit_inode(NULL, filp->f_path.dentry);
info = MQUEUE_I(inode);
audit_inode(NULL, filp->f_path.dentry);
- if (unlikely(!(filp->f_mode & FMODE_READ)))
+ if (unlikely(!(filp->f_mode & FMODE_READ))) {
+ ret = -EBADF;
/* checks if buffer is big enough */
if (unlikely(msg_len < info->attr.mq_msgsize)) {
/* checks if buffer is big enough */
if (unlikely(msg_len < info->attr.mq_msgsize)) {
/* create the notify skb */
nc = alloc_skb(NOTIFY_COOKIE_LEN, GFP_KERNEL);
/* create the notify skb */
nc = alloc_skb(NOTIFY_COOKIE_LEN, GFP_KERNEL);
- ret = -ENOMEM;
- if (!nc)
+ if (!nc) {
+ ret = -ENOMEM;
if (copy_from_user(nc->data,
notification.sigev_value.sival_ptr,
NOTIFY_COOKIE_LEN)) {
if (copy_from_user(nc->data,
notification.sigev_value.sival_ptr,
NOTIFY_COOKIE_LEN)) {
/* and attach it to the socket */
retry:
filp = fget(notification.sigev_signo);
/* and attach it to the socket */
retry:
filp = fget(notification.sigev_signo);
- ret = -EBADF;
- if (!filp)
+ if (!filp) {
+ ret = -EBADF;
sock = netlink_getsockbyfilp(filp);
fput(filp);
if (IS_ERR(sock)) {
sock = netlink_getsockbyfilp(filp);
fput(filp);
if (IS_ERR(sock)) {
timeo = MAX_SCHEDULE_TIMEOUT;
ret = netlink_attachskb(sock, nc, &timeo, NULL);
if (ret == 1)
timeo = MAX_SCHEDULE_TIMEOUT;
ret = netlink_attachskb(sock, nc, &timeo, NULL);
if (ret == 1)
if (ret) {
sock = NULL;
nc = NULL;
if (ret) {
sock = NULL;
nc = NULL;
+ if (!filp) {
+ ret = -EBADF;
inode = filp->f_path.dentry->d_inode;
inode = filp->f_path.dentry->d_inode;
- if (unlikely(filp->f_op != &mqueue_file_operations))
+ if (unlikely(filp->f_op != &mqueue_file_operations)) {
+ ret = -EBADF;
info = MQUEUE_I(inode);
ret = 0;
info = MQUEUE_I(inode);
ret = 0;
+ if (!filp) {
+ ret = -EBADF;
inode = filp->f_path.dentry->d_inode;
inode = filp->f_path.dentry->d_inode;
- if (unlikely(filp->f_op != &mqueue_file_operations))
+ if (unlikely(filp->f_op != &mqueue_file_operations)) {
+ ret = -EBADF;
info = MQUEUE_I(inode);
spin_lock(&info->lock);
info = MQUEUE_I(inode);
spin_lock(&info->lock);