Commit 0fdf68c7 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'media/v5.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media

Pull media fixes from Mauro Carvalho Chehab:

 - a compilation fix issue with ti-vpe on arm 32 bits

 - two Kconfig fixes for imx214 and max9286 drivers

 - a kernel information leak at v4l2-core on time32 compat ioctls

 - some fixes at rc core unbind logic

 - a fix at mceusb driver for it to not use GFP_ATOMIC

 - fixes at cedrus and vicodec drivers at the control handling logic

 - a fix at gpio-ir-tx to avoid disabling interruts on a spinlock

* tag 'media/v5.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
  media: mceusb: Avoid GFP_ATOMIC where it is not needed
  media: gpio-ir-tx: spinlock is not needed to disable interrupts
  media: rc: do not access device via sysfs after rc_unregister_device()
  media: rc: uevent sysfs file races with rc_unregister_device()
  media: max9286: Depend on OF_GPIO
  media: i2c: imx214: select V4L2_FWNODE
  media: cedrus: Add missing v4l2_ctrl_request_hdl_put()
  media: vicodec: add missing v4l2_ctrl_request_hdl_put()
  media: media/v4l2-core: Fix kernel-infoleak in video_put_user()
  media: ti-vpe: cal: Fix compilation on 32-bit ARM
parents fc3abb53 ddecfc76
...@@ -467,7 +467,7 @@ config VIDEO_VPX3220 ...@@ -467,7 +467,7 @@ config VIDEO_VPX3220
config VIDEO_MAX9286 config VIDEO_MAX9286
tristate "Maxim MAX9286 GMSL deserializer support" tristate "Maxim MAX9286 GMSL deserializer support"
depends on I2C && I2C_MUX depends on I2C && I2C_MUX
depends on OF depends on OF_GPIO
select V4L2_FWNODE select V4L2_FWNODE
select VIDEO_V4L2_SUBDEV_API select VIDEO_V4L2_SUBDEV_API
select MEDIA_CONTROLLER select MEDIA_CONTROLLER
...@@ -741,7 +741,7 @@ config VIDEO_HI556 ...@@ -741,7 +741,7 @@ config VIDEO_HI556
config VIDEO_IMX214 config VIDEO_IMX214
tristate "Sony IMX214 sensor support" tristate "Sony IMX214 sensor support"
depends on GPIOLIB && I2C && VIDEO_V4L2 depends on GPIOLIB && I2C && VIDEO_V4L2
depends on V4L2_FWNODE select V4L2_FWNODE
select MEDIA_CONTROLLER select MEDIA_CONTROLLER
select VIDEO_V4L2_SUBDEV_API select VIDEO_V4L2_SUBDEV_API
select REGMAP_I2C select REGMAP_I2C
......
...@@ -226,7 +226,7 @@ static inline void cal_write_field(struct cal_dev *cal, u32 offset, u32 value, ...@@ -226,7 +226,7 @@ static inline void cal_write_field(struct cal_dev *cal, u32 offset, u32 value,
u32 val = cal_read(cal, offset); u32 val = cal_read(cal, offset);
val &= ~mask; val &= ~mask;
val |= FIELD_PREP(mask, value); val |= (value << __ffs(mask)) & mask;
cal_write(cal, offset, val); cal_write(cal, offset, val);
} }
......
...@@ -19,8 +19,6 @@ struct gpio_ir { ...@@ -19,8 +19,6 @@ struct gpio_ir {
struct gpio_desc *gpio; struct gpio_desc *gpio;
unsigned int carrier; unsigned int carrier;
unsigned int duty_cycle; unsigned int duty_cycle;
/* we need a spinlock to hold the cpu while transmitting */
spinlock_t lock;
}; };
static const struct of_device_id gpio_ir_tx_of_match[] = { static const struct of_device_id gpio_ir_tx_of_match[] = {
...@@ -53,12 +51,11 @@ static int gpio_ir_tx_set_carrier(struct rc_dev *dev, u32 carrier) ...@@ -53,12 +51,11 @@ static int gpio_ir_tx_set_carrier(struct rc_dev *dev, u32 carrier)
static void gpio_ir_tx_unmodulated(struct gpio_ir *gpio_ir, uint *txbuf, static void gpio_ir_tx_unmodulated(struct gpio_ir *gpio_ir, uint *txbuf,
uint count) uint count)
{ {
unsigned long flags;
ktime_t edge; ktime_t edge;
s32 delta; s32 delta;
int i; int i;
spin_lock_irqsave(&gpio_ir->lock, flags); local_irq_disable();
edge = ktime_get(); edge = ktime_get();
...@@ -72,14 +69,11 @@ static void gpio_ir_tx_unmodulated(struct gpio_ir *gpio_ir, uint *txbuf, ...@@ -72,14 +69,11 @@ static void gpio_ir_tx_unmodulated(struct gpio_ir *gpio_ir, uint *txbuf,
} }
gpiod_set_value(gpio_ir->gpio, 0); gpiod_set_value(gpio_ir->gpio, 0);
spin_unlock_irqrestore(&gpio_ir->lock, flags);
} }
static void gpio_ir_tx_modulated(struct gpio_ir *gpio_ir, uint *txbuf, static void gpio_ir_tx_modulated(struct gpio_ir *gpio_ir, uint *txbuf,
uint count) uint count)
{ {
unsigned long flags;
ktime_t edge; ktime_t edge;
/* /*
* delta should never exceed 0.5 seconds (IR_MAX_DURATION) and on * delta should never exceed 0.5 seconds (IR_MAX_DURATION) and on
...@@ -95,7 +89,7 @@ static void gpio_ir_tx_modulated(struct gpio_ir *gpio_ir, uint *txbuf, ...@@ -95,7 +89,7 @@ static void gpio_ir_tx_modulated(struct gpio_ir *gpio_ir, uint *txbuf,
space = DIV_ROUND_CLOSEST((100 - gpio_ir->duty_cycle) * space = DIV_ROUND_CLOSEST((100 - gpio_ir->duty_cycle) *
(NSEC_PER_SEC / 100), gpio_ir->carrier); (NSEC_PER_SEC / 100), gpio_ir->carrier);
spin_lock_irqsave(&gpio_ir->lock, flags); local_irq_disable();
edge = ktime_get(); edge = ktime_get();
...@@ -128,19 +122,20 @@ static void gpio_ir_tx_modulated(struct gpio_ir *gpio_ir, uint *txbuf, ...@@ -128,19 +122,20 @@ static void gpio_ir_tx_modulated(struct gpio_ir *gpio_ir, uint *txbuf,
edge = last; edge = last;
} }
} }
spin_unlock_irqrestore(&gpio_ir->lock, flags);
} }
static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf, static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
unsigned int count) unsigned int count)
{ {
struct gpio_ir *gpio_ir = dev->priv; struct gpio_ir *gpio_ir = dev->priv;
unsigned long flags;
local_irq_save(flags);
if (gpio_ir->carrier) if (gpio_ir->carrier)
gpio_ir_tx_modulated(gpio_ir, txbuf, count); gpio_ir_tx_modulated(gpio_ir, txbuf, count);
else else
gpio_ir_tx_unmodulated(gpio_ir, txbuf, count); gpio_ir_tx_unmodulated(gpio_ir, txbuf, count);
local_irq_restore(flags);
return count; return count;
} }
...@@ -176,7 +171,6 @@ static int gpio_ir_tx_probe(struct platform_device *pdev) ...@@ -176,7 +171,6 @@ static int gpio_ir_tx_probe(struct platform_device *pdev)
gpio_ir->carrier = 38000; gpio_ir->carrier = 38000;
gpio_ir->duty_cycle = 50; gpio_ir->duty_cycle = 50;
spin_lock_init(&gpio_ir->lock);
rc = devm_rc_register_device(&pdev->dev, rcdev); rc = devm_rc_register_device(&pdev->dev, rcdev);
if (rc < 0) if (rc < 0)
......
...@@ -1726,7 +1726,7 @@ static int mceusb_dev_probe(struct usb_interface *intf, ...@@ -1726,7 +1726,7 @@ static int mceusb_dev_probe(struct usb_interface *intf,
goto mem_alloc_fail; goto mem_alloc_fail;
ir->pipe_in = pipe; ir->pipe_in = pipe;
ir->buf_in = usb_alloc_coherent(dev, maxp, GFP_ATOMIC, &ir->dma_in); ir->buf_in = usb_alloc_coherent(dev, maxp, GFP_KERNEL, &ir->dma_in);
if (!ir->buf_in) if (!ir->buf_in)
goto buf_in_alloc_fail; goto buf_in_alloc_fail;
......
...@@ -1292,6 +1292,10 @@ static ssize_t store_protocols(struct device *device, ...@@ -1292,6 +1292,10 @@ static ssize_t store_protocols(struct device *device,
} }
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
if (!dev->registered) {
mutex_unlock(&dev->lock);
return -ENODEV;
}
old_protocols = *current_protocols; old_protocols = *current_protocols;
new_protocols = old_protocols; new_protocols = old_protocols;
...@@ -1430,6 +1434,10 @@ static ssize_t store_filter(struct device *device, ...@@ -1430,6 +1434,10 @@ static ssize_t store_filter(struct device *device,
return -EINVAL; return -EINVAL;
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
if (!dev->registered) {
mutex_unlock(&dev->lock);
return -ENODEV;
}
new_filter = *filter; new_filter = *filter;
if (fattr->mask) if (fattr->mask)
...@@ -1544,6 +1552,10 @@ static ssize_t store_wakeup_protocols(struct device *device, ...@@ -1544,6 +1552,10 @@ static ssize_t store_wakeup_protocols(struct device *device,
int i; int i;
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
if (!dev->registered) {
mutex_unlock(&dev->lock);
return -ENODEV;
}
allowed = dev->allowed_wakeup_protocols; allowed = dev->allowed_wakeup_protocols;
...@@ -1601,25 +1613,25 @@ static void rc_dev_release(struct device *device) ...@@ -1601,25 +1613,25 @@ static void rc_dev_release(struct device *device)
kfree(dev); kfree(dev);
} }
#define ADD_HOTPLUG_VAR(fmt, val...) \
do { \
int err = add_uevent_var(env, fmt, val); \
if (err) \
return err; \
} while (0)
static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env) static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env)
{ {
struct rc_dev *dev = to_rc_dev(device); struct rc_dev *dev = to_rc_dev(device);
int ret = 0;
if (dev->rc_map.name) mutex_lock(&dev->lock);
ADD_HOTPLUG_VAR("NAME=%s", dev->rc_map.name);
if (dev->driver_name)
ADD_HOTPLUG_VAR("DRV_NAME=%s", dev->driver_name);
if (dev->device_name)
ADD_HOTPLUG_VAR("DEV_NAME=%s", dev->device_name);
return 0; if (!dev->registered)
ret = -ENODEV;
if (ret == 0 && dev->rc_map.name)
ret = add_uevent_var(env, "NAME=%s", dev->rc_map.name);
if (ret == 0 && dev->driver_name)
ret = add_uevent_var(env, "DRV_NAME=%s", dev->driver_name);
if (ret == 0 && dev->device_name)
ret = add_uevent_var(env, "DEV_NAME=%s", dev->device_name);
mutex_unlock(&dev->lock);
return ret;
} }
/* /*
...@@ -2011,14 +2023,14 @@ void rc_unregister_device(struct rc_dev *dev) ...@@ -2011,14 +2023,14 @@ void rc_unregister_device(struct rc_dev *dev)
del_timer_sync(&dev->timer_keyup); del_timer_sync(&dev->timer_keyup);
del_timer_sync(&dev->timer_repeat); del_timer_sync(&dev->timer_repeat);
rc_free_rx_device(dev);
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
if (dev->users && dev->close) if (dev->users && dev->close)
dev->close(dev); dev->close(dev);
dev->registered = false; dev->registered = false;
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
rc_free_rx_device(dev);
/* /*
* lirc device should be freed with dev->registered = false, so * lirc device should be freed with dev->registered = false, so
* that userspace polling will get notified. * that userspace polling will get notified.
......
...@@ -1994,6 +1994,7 @@ static int vicodec_request_validate(struct media_request *req) ...@@ -1994,6 +1994,7 @@ static int vicodec_request_validate(struct media_request *req)
} }
ctrl = v4l2_ctrl_request_hdl_ctrl_find(hdl, ctrl = v4l2_ctrl_request_hdl_ctrl_find(hdl,
vicodec_ctrl_stateless_state.id); vicodec_ctrl_stateless_state.id);
v4l2_ctrl_request_hdl_put(hdl);
if (!ctrl) { if (!ctrl) {
v4l2_info(&ctx->dev->v4l2_dev, v4l2_info(&ctx->dev->v4l2_dev,
"Missing required codec control\n"); "Missing required codec control\n");
......
...@@ -3187,14 +3187,16 @@ static int video_put_user(void __user *arg, void *parg, unsigned int cmd) ...@@ -3187,14 +3187,16 @@ static int video_put_user(void __user *arg, void *parg, unsigned int cmd)
#ifdef CONFIG_COMPAT_32BIT_TIME #ifdef CONFIG_COMPAT_32BIT_TIME
case VIDIOC_DQEVENT_TIME32: { case VIDIOC_DQEVENT_TIME32: {
struct v4l2_event *ev = parg; struct v4l2_event *ev = parg;
struct v4l2_event_time32 ev32 = { struct v4l2_event_time32 ev32;
.type = ev->type,
.pending = ev->pending, memset(&ev32, 0, sizeof(ev32));
.sequence = ev->sequence,
.timestamp.tv_sec = ev->timestamp.tv_sec, ev32.type = ev->type;
.timestamp.tv_nsec = ev->timestamp.tv_nsec, ev32.pending = ev->pending;
.id = ev->id, ev32.sequence = ev->sequence;
}; ev32.timestamp.tv_sec = ev->timestamp.tv_sec;
ev32.timestamp.tv_nsec = ev->timestamp.tv_nsec;
ev32.id = ev->id;
memcpy(&ev32.u, &ev->u, sizeof(ev->u)); memcpy(&ev32.u, &ev->u, sizeof(ev->u));
memcpy(&ev32.reserved, &ev->reserved, sizeof(ev->reserved)); memcpy(&ev32.reserved, &ev->reserved, sizeof(ev->reserved));
...@@ -3208,21 +3210,23 @@ static int video_put_user(void __user *arg, void *parg, unsigned int cmd) ...@@ -3208,21 +3210,23 @@ static int video_put_user(void __user *arg, void *parg, unsigned int cmd)
case VIDIOC_DQBUF_TIME32: case VIDIOC_DQBUF_TIME32:
case VIDIOC_PREPARE_BUF_TIME32: { case VIDIOC_PREPARE_BUF_TIME32: {
struct v4l2_buffer *vb = parg; struct v4l2_buffer *vb = parg;
struct v4l2_buffer_time32 vb32 = { struct v4l2_buffer_time32 vb32;
.index = vb->index,
.type = vb->type, memset(&vb32, 0, sizeof(vb32));
.bytesused = vb->bytesused,
.flags = vb->flags, vb32.index = vb->index;
.field = vb->field, vb32.type = vb->type;
.timestamp.tv_sec = vb->timestamp.tv_sec, vb32.bytesused = vb->bytesused;
.timestamp.tv_usec = vb->timestamp.tv_usec, vb32.flags = vb->flags;
.timecode = vb->timecode, vb32.field = vb->field;
.sequence = vb->sequence, vb32.timestamp.tv_sec = vb->timestamp.tv_sec;
.memory = vb->memory, vb32.timestamp.tv_usec = vb->timestamp.tv_usec;
.m.userptr = vb->m.userptr, vb32.timecode = vb->timecode;
.length = vb->length, vb32.sequence = vb->sequence;
.request_fd = vb->request_fd, vb32.memory = vb->memory;
}; vb32.m.userptr = vb->m.userptr;
vb32.length = vb->length;
vb32.request_fd = vb->request_fd;
if (copy_to_user(arg, &vb32, sizeof(vb32))) if (copy_to_user(arg, &vb32, sizeof(vb32)))
return -EFAULT; return -EFAULT;
......
...@@ -199,6 +199,7 @@ static int cedrus_request_validate(struct media_request *req) ...@@ -199,6 +199,7 @@ static int cedrus_request_validate(struct media_request *req)
struct v4l2_ctrl *ctrl_test; struct v4l2_ctrl *ctrl_test;
unsigned int count; unsigned int count;
unsigned int i; unsigned int i;
int ret = 0;
list_for_each_entry(obj, &req->objects, list) { list_for_each_entry(obj, &req->objects, list) {
struct vb2_buffer *vb; struct vb2_buffer *vb;
...@@ -243,12 +244,16 @@ static int cedrus_request_validate(struct media_request *req) ...@@ -243,12 +244,16 @@ static int cedrus_request_validate(struct media_request *req)
if (!ctrl_test) { if (!ctrl_test) {
v4l2_info(&ctx->dev->v4l2_dev, v4l2_info(&ctx->dev->v4l2_dev,
"Missing required codec control\n"); "Missing required codec control\n");
return -ENOENT; ret = -ENOENT;
break;
} }
} }
v4l2_ctrl_request_hdl_put(hdl); v4l2_ctrl_request_hdl_put(hdl);
if (ret)
return ret;
return vb2_request_validate(req); return vb2_request_validate(req);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment