Merge branch 'tbsdtv_linux_media/master' into tbsdtv_linux_media/latest

This commit is contained in:
CrazyCat
2025-03-18 23:03:14 +02:00
5 changed files with 37 additions and 29 deletions

View File

@@ -731,7 +731,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
ret = (*secfeed)->allocate_filter(*secfeed, secfilter); ret = (*secfeed)->allocate_filter(*secfeed, secfilter);
if (ret < 0) { if (ret < 0) {
dvb_dmxdev_feed_restart(filter); dvb_dmxdev_feed_restart(filter);
filter->feed.sec->start_filtering(*secfeed); *secfeed = NULL;
dprintk("could not get filter\n"); dprintk("could not get filter\n");
return ret; return ret;
} }

View File

@@ -443,8 +443,8 @@ static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wra
default: default:
fepriv->auto_step++; fepriv->auto_step++;
fepriv->auto_sub_step = -1; /* it'll be incremented to 0 in a moment */ fepriv->auto_sub_step = 0;
break; continue;
} }
if (!ready) fepriv->auto_sub_step++; if (!ready) fepriv->auto_sub_step++;
@@ -679,11 +679,9 @@ static int dvb_frontend_thread(void *data)
set_freezable(); set_freezable();
while (1) { while (1) {
up(&fepriv->sem); /* is locked when we enter the thread... */ up(&fepriv->sem); /* is locked when we enter the thread... */
restart: wait_event_freezable_timeout(fepriv->wait_queue,
wait_event_interruptible_timeout(fepriv->wait_queue,
dvb_frontend_should_wakeup(fe) || dvb_frontend_should_wakeup(fe) ||
kthread_should_stop() || kthread_should_stop(),
freezing(current),
fepriv->delay); fepriv->delay);
if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) { if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) {
@@ -694,9 +692,6 @@ restart:
break; break;
} }
if (try_to_freeze())
goto restart;
if (down_interruptible(&fepriv->sem)) if (down_interruptible(&fepriv->sem))
break; break;
@@ -2185,7 +2180,8 @@ static int dvb_frontend_handle_compat_ioctl(struct file *file, unsigned int cmd,
if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS)) if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
return -EINVAL; return -EINVAL;
tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp)); tvp = memdup_array_user(compat_ptr(tvps->props),
tvps->num, sizeof(*tvp));
if (IS_ERR(tvp)) if (IS_ERR(tvp))
return PTR_ERR(tvp); return PTR_ERR(tvp);
@@ -2216,7 +2212,8 @@ static int dvb_frontend_handle_compat_ioctl(struct file *file, unsigned int cmd,
if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS)) if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
return -EINVAL; return -EINVAL;
tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp)); tvp = memdup_array_user(compat_ptr(tvps->props),
tvps->num, sizeof(*tvp));
if (IS_ERR(tvp)) if (IS_ERR(tvp))
return PTR_ERR(tvp); return PTR_ERR(tvp);
@@ -2396,7 +2393,8 @@ static int dvb_get_property(struct dvb_frontend *fe, struct file *file,
if (!tvps->num || tvps->num > DTV_IOCTL_MAX_MSGS) if (!tvps->num || tvps->num > DTV_IOCTL_MAX_MSGS)
return -EINVAL; return -EINVAL;
tvp = memdup_user((void __user *)tvps->props, tvps->num * sizeof(*tvp)); tvp = memdup_array_user((void __user *)tvps->props,
tvps->num, sizeof(*tvp));
if (IS_ERR(tvp)) if (IS_ERR(tvp))
return PTR_ERR(tvp); return PTR_ERR(tvp);
@@ -2545,7 +2543,8 @@ static int dvb_frontend_handle_ioctl(struct file *file,
if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS)) if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
return -EINVAL; return -EINVAL;
tvp = memdup_user((void __user *)tvps->props, tvps->num * sizeof(*tvp)); tvp = memdup_array_user((void __user *)tvps->props,
tvps->num, sizeof(*tvp));
if (IS_ERR(tvp)) if (IS_ERR(tvp))
return PTR_ERR(tvp); return PTR_ERR(tvp);

View File

@@ -86,10 +86,15 @@ static DECLARE_RWSEM(minor_rwsem);
static int dvb_device_open(struct inode *inode, struct file *file) static int dvb_device_open(struct inode *inode, struct file *file)
{ {
struct dvb_device *dvbdev; struct dvb_device *dvbdev;
unsigned int minor = iminor(inode);
if (minor >= MAX_DVB_MINORS)
return -ENODEV;
mutex_lock(&dvbdev_mutex); mutex_lock(&dvbdev_mutex);
down_read(&minor_rwsem); down_read(&minor_rwsem);
dvbdev = dvb_minors[iminor(inode)];
dvbdev = dvb_minors[minor];
if (dvbdev && dvbdev->fops) { if (dvbdev && dvbdev->fops) {
int err = 0; int err = 0;
@@ -104,6 +109,8 @@ static int dvb_device_open(struct inode *inode, struct file *file)
err = file->f_op->open(inode, file); err = file->f_op->open(inode, file);
up_read(&minor_rwsem); up_read(&minor_rwsem);
mutex_unlock(&dvbdev_mutex); mutex_unlock(&dvbdev_mutex);
if (err)
dvb_device_put(dvbdev);
return err; return err;
} }
fail: fail:
@@ -488,6 +495,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
dvbdevfops = kmemdup(template->fops, sizeof(*dvbdevfops), GFP_KERNEL); dvbdevfops = kmemdup(template->fops, sizeof(*dvbdevfops), GFP_KERNEL);
if (!dvbdevfops) { if (!dvbdevfops) {
kfree(dvbdev); kfree(dvbdev);
*pdvbdev = NULL;
mutex_unlock(&dvbdev_register_lock); mutex_unlock(&dvbdev_register_lock);
return -ENOMEM; return -ENOMEM;
} }
@@ -496,6 +504,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
if (!new_node) { if (!new_node) {
kfree(dvbdevfops); kfree(dvbdevfops);
kfree(dvbdev); kfree(dvbdev);
*pdvbdev = NULL;
mutex_unlock(&dvbdev_register_lock); mutex_unlock(&dvbdev_register_lock);
return -ENOMEM; return -ENOMEM;
} }
@@ -521,7 +530,10 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
for (minor = 0; minor < MAX_DVB_MINORS; minor++) for (minor = 0; minor < MAX_DVB_MINORS; minor++)
if (!dvb_minors[minor]) if (!dvb_minors[minor])
break; break;
if (minor == MAX_DVB_MINORS) { #else
minor = nums2minor(adap->num, type, id);
#endif
if (minor >= MAX_DVB_MINORS) {
if (new_node) { if (new_node) {
list_del(&new_node->list_head); list_del(&new_node->list_head);
kfree(dvbdevfops); kfree(dvbdevfops);
@@ -529,13 +541,12 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
} }
list_del(&dvbdev->list_head); list_del(&dvbdev->list_head);
kfree(dvbdev); kfree(dvbdev);
*pdvbdev = NULL;
up_write(&minor_rwsem); up_write(&minor_rwsem);
mutex_unlock(&dvbdev_register_lock); mutex_unlock(&dvbdev_register_lock);
return -EINVAL; return -EINVAL;
} }
#else
minor = nums2minor(adap->num, type, id);
#endif
dvbdev->minor = minor; dvbdev->minor = minor;
dvb_minors[minor] = dvb_device_get(dvbdev); dvb_minors[minor] = dvb_device_get(dvbdev);
up_write(&minor_rwsem); up_write(&minor_rwsem);
@@ -551,6 +562,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
dvb_media_device_free(dvbdev); dvb_media_device_free(dvbdev);
list_del(&dvbdev->list_head); list_del(&dvbdev->list_head);
kfree(dvbdev); kfree(dvbdev);
*pdvbdev = NULL;
mutex_unlock(&dvbdev_register_lock); mutex_unlock(&dvbdev_register_lock);
return ret; return ret;
} }
@@ -569,6 +581,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
dvb_media_device_free(dvbdev); dvb_media_device_free(dvbdev);
list_del(&dvbdev->list_head); list_del(&dvbdev->list_head);
kfree(dvbdev); kfree(dvbdev);
*pdvbdev = NULL;
mutex_unlock(&dvbdev_register_lock); mutex_unlock(&dvbdev_register_lock);
return PTR_ERR(clsdev); return PTR_ERR(clsdev);
} }
@@ -949,7 +962,7 @@ int dvb_usercopy(struct file *file,
int (*func)(struct file *file, int (*func)(struct file *file,
unsigned int cmd, void *arg)) unsigned int cmd, void *arg))
{ {
char sbuf[128]; char sbuf[128] = {};
void *mbuf = NULL; void *mbuf = NULL;
void *parg = NULL; void *parg = NULL;
int err = -EINVAL; int err = -EINVAL;

View File

@@ -311,12 +311,8 @@ static int cxd2841er_set_reg_bits(struct cxd2841er_priv *priv,
static u32 cxd2841er_calc_iffreq_xtal(enum cxd2841er_xtal xtal, u32 ifhz) static u32 cxd2841er_calc_iffreq_xtal(enum cxd2841er_xtal xtal, u32 ifhz)
{ {
u64 tmp; return div_u64(ifhz * 16777216ull,
(xtal == SONY_XTAL_24000) ? 48000000 : 41000000);
tmp = (u64) ifhz * 16777216;
do_div(tmp, ((xtal == SONY_XTAL_24000) ? 48000000 : 41000000));
return (u32) tmp;
} }
static u32 cxd2841er_calc_iffreq(u32 ifhz) static u32 cxd2841er_calc_iffreq(u32 ifhz)

View File

@@ -983,7 +983,7 @@ static int rtl2832_pid_filter(struct dvb_frontend *fe, u8 index, u16 pid,
index, pid, onoff, dev->slave_ts); index, pid, onoff, dev->slave_ts);
/* skip invalid PIDs (0x2000) */ /* skip invalid PIDs (0x2000) */
if (pid > 0x1fff || index > 32) if (pid > 0x1fff || index >= 32)
return 0; return 0;
if (onoff) if (onoff)