Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions drivers/staging/vc04_services/vc-sm-cma/vc_sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <linux/dma-mapping.h>
#include <linux/dma-buf.h>
#include <linux/errno.h>
#include <linux/fdtable.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/list.h>
Expand Down Expand Up @@ -1200,8 +1201,10 @@ static int vc_sm_cma_ioctl_alloc(struct vc_sm_privdata_t *private,
buffer->alloc.sg_table = sgt;

fd = dma_buf_fd(dmabuf, O_CLOEXEC);
if (fd < 0)
if (fd < 0) {
ret = fd;
goto error;
}

vc_sm_add_resource(private, buffer);

Expand Down Expand Up @@ -1276,9 +1279,9 @@ static long vc_sm_cma_ioctl(struct file *file, unsigned int cmd,
if (!ret &&
(copy_to_user((void *)arg, &ioparam,
sizeof(ioparam)) != 0)) {
/* FIXME: Release allocation */
pr_err("[%s]: failed to copy-to-user for cmd %x\n",
__func__, cmdnr);
close_fd(ioparam.handle);
ret = -EFAULT;
}
break;
Expand Down Expand Up @@ -1312,11 +1315,12 @@ static long vc_sm_cma_ioctl(struct file *file, unsigned int cmd,
ioparam.vc_handle = buf->vc_handle;
ioparam.dma_addr = buf->dma_addr;

if (ioparam.handle < 0 ||
(copy_to_user((void *)arg, &ioparam,
sizeof(ioparam)) != 0)) {
if (ioparam.handle < 0) {
dma_buf_put(new_dmabuf);
/* FIXME: Release allocation */
ret = -EFAULT;
} else if (copy_to_user((void *)arg, &ioparam,
sizeof(ioparam)) != 0) {
close_fd(ioparam.handle);
ret = -EFAULT;
}
}
Expand Down
6 changes: 6 additions & 0 deletions drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,9 @@ static int port_parameter_set(struct vchiq_mmal_instance *instance,
struct mmal_msg *rmsg;
struct vchiq_header *rmsg_handle;

if (value_size > sizeof(m.u.port_parameter_set.value))
return -EINVAL;

m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_SET;

m.u.port_parameter_set.component_handle = port->component->handle;
Expand Down Expand Up @@ -1390,6 +1393,9 @@ static int port_parameter_get(struct vchiq_mmal_instance *instance,
struct mmal_msg *rmsg;
struct vchiq_header *rmsg_handle;

if (*value_size > sizeof(rmsg->u.port_parameter_get_reply.value))
return -EINVAL;

m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_GET;

m.u.port_parameter_get.component_handle = port->component->handle;
Expand Down
Loading