Unverified Commit 64b082bd authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!10296 Backport dvb-usb bugfix

Merge Pull Request from: @ci-robot 
 
PR sync from: Zheng Yejian <zhengyejian1@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/CMLNISJWXRYDFAS4W4GEMQXOCDGBUQZM/ 
Greg Kroah-Hartman (1):
  USB: move snd_usb_pipe_sanity_check into the USB core

Zheng Yejian (1):
  media: dvb-usb: Fix unexpected infinite loop in
    dvb_usb_read_remote_control()


-- 
2.25.1
 
https://gitee.com/openeuler/kernel/issues/IAEPSH 
 
Link:https://gitee.com/openeuler/kernel/pulls/10296

 

Reviewed-by: default avatarYe Weihua <yeweihua4@huawei.com>
Reviewed-by: default avatarXu Kuohai <xukuohai@huawei.com>
Reviewed-by: default avatarLiu YongQiang <liuyongqiang13@huawei.com>
Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
parents 9bfba252 35b35c8a
Loading
Loading
Loading
Loading
+31 −4
Original line number Diff line number Diff line
@@ -26,11 +26,40 @@ static int dvb_usb_force_pid_filter_usage;
module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage, int, 0444);
MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a PID filter, if any (default: 0).");

static int dvb_usb_check_bulk_endpoint(struct dvb_usb_device *d, u8 endpoint)
{
	if (endpoint) {
		int ret;

		ret = usb_pipe_type_check(d->udev, usb_sndbulkpipe(d->udev, endpoint));
		if (ret)
			return ret;
		ret = usb_pipe_type_check(d->udev, usb_rcvbulkpipe(d->udev, endpoint));
		if (ret)
			return ret;
	}
	return 0;
}

static void dvb_usb_clear_halt(struct dvb_usb_device *d, u8 endpoint)
{
	if (endpoint) {
		usb_clear_halt(d->udev, usb_sndbulkpipe(d->udev, endpoint));
		usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, endpoint));
	}
}

static int dvb_usb_adapter_init(struct dvb_usb_device *d, short *adapter_nrs)
{
	struct dvb_usb_adapter *adap;
	int ret, n, o;

	ret = dvb_usb_check_bulk_endpoint(d, d->props.generic_bulk_ctrl_endpoint);
	if (ret)
		return ret;
	ret = dvb_usb_check_bulk_endpoint(d, d->props.generic_bulk_ctrl_endpoint_response);
	if (ret)
		return ret;
	for (n = 0; n < d->props.num_adapters; n++) {
		adap = &d->adapter[n];
		adap->dev = d;
@@ -100,10 +129,8 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d, short *adapter_nrs)
	 * when reloading the driver w/o replugging the device
	 * sometimes a timeout occures, this helps
	 */
	if (d->props.generic_bulk_ctrl_endpoint != 0) {
		usb_clear_halt(d->udev, usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
		usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
	}
	dvb_usb_clear_halt(d, d->props.generic_bulk_ctrl_endpoint);
	dvb_usb_clear_halt(d, d->props.generic_bulk_ctrl_endpoint_response);

	return 0;
}
+23 −8
Original line number Diff line number Diff line
@@ -193,24 +193,39 @@ static const int pipetypes[4] = {
};

/**
 * usb_urb_ep_type_check - sanity check of endpoint in the given urb
 * @urb: urb to be checked
 * usb_pipe_type_check - sanity check of a specific pipe for a usb device
 * @dev: struct usb_device to be checked
 * @pipe: pipe to check
 *
 * This performs a light-weight sanity check for the endpoint in the
 * given urb.  It returns 0 if the urb contains a valid endpoint, otherwise
 * a negative error code.
 * given usb device.  It returns 0 if the pipe is valid for the specific usb
 * device, otherwise a negative error code.
 */
int usb_urb_ep_type_check(const struct urb *urb)
int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe)
{
	const struct usb_host_endpoint *ep;

	ep = usb_pipe_endpoint(urb->dev, urb->pipe);
	ep = usb_pipe_endpoint(dev, pipe);
	if (!ep)
		return -EINVAL;
	if (usb_pipetype(urb->pipe) != pipetypes[usb_endpoint_type(&ep->desc)])
	if (usb_pipetype(pipe) != pipetypes[usb_endpoint_type(&ep->desc)])
		return -EINVAL;
	return 0;
}
EXPORT_SYMBOL_GPL(usb_pipe_type_check);

/**
 * usb_urb_ep_type_check - sanity check of endpoint in the given urb
 * @urb: urb to be checked
 *
 * This performs a light-weight sanity check for the endpoint in the
 * given urb.  It returns 0 if the urb contains a valid endpoint, otherwise
 * a negative error code.
 */
int usb_urb_ep_type_check(const struct urb *urb)
{
	return usb_pipe_type_check(urb->dev, urb->pipe);
}
EXPORT_SYMBOL_GPL(usb_urb_ep_type_check);

/**
@@ -475,7 +490,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
	 */

	/* Check that the pipe's type matches the endpoint's type */
	if (usb_urb_ep_type_check(urb))
	if (usb_pipe_type_check(urb->dev, urb->pipe))
		dev_WARN(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n",
			usb_pipetype(urb->pipe), pipetypes[xfertype]);

+1 −0
Original line number Diff line number Diff line
@@ -1757,6 +1757,7 @@ static inline int usb_urb_dir_out(struct urb *urb)
	return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT;
}

int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe);
int usb_urb_ep_type_check(const struct urb *urb);

void *usb_alloc_coherent(struct usb_device *dev, size_t size,