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

!4710 CVE-2021-46904 for openEuler1.0

Merge Pull Request from: @ci-robot 
 
PR sync from: Liu Jian <liujian56@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/6ZSESBZNWEVJ2KQ34USYCSKOQJMXEI4S/ 
Anirudh Rayabharam (1):
  net: hso: fix null-ptr-deref during tty device unregistration

Johan Hovold (1):
  net: hso: fix NULL-deref on disconnect regression

Rustam Kovhaev (1):
  usb: hso: check for return value in hso_serial_common_create()


-- 
2.34.1
 
https://gitee.com/src-openeuler/kernel/issues/I93LMH 
 
Link:https://gitee.com/openeuler/kernel/pulls/4710

 

Reviewed-by: default avatarYue Haibing <yuehaibing@huawei.com>
Reviewed-by: default avatarLiu YongQiang <liuyongqiang13@huawei.com>
Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
parents 8216cdc4 ffa0d69d
Loading
Loading
Loading
Loading
+16 −22
Original line number Diff line number Diff line
@@ -625,7 +625,7 @@ static struct hso_serial *get_serial_by_index(unsigned index)
	return serial;
}

static int get_free_serial_index(void)
static int obtain_minor(struct hso_serial *serial)
{
	int index;
	unsigned long flags;
@@ -633,8 +633,10 @@ static int get_free_serial_index(void)
	spin_lock_irqsave(&serial_table_lock, flags);
	for (index = 0; index < HSO_SERIAL_TTY_MINORS; index++) {
		if (serial_table[index] == NULL) {
			serial_table[index] = serial->parent;
			serial->minor = index;
			spin_unlock_irqrestore(&serial_table_lock, flags);
			return index;
			return 0;
		}
	}
	spin_unlock_irqrestore(&serial_table_lock, flags);
@@ -643,15 +645,12 @@ static int get_free_serial_index(void)
	return -1;
}

static void set_serial_by_index(unsigned index, struct hso_serial *serial)
static void release_minor(struct hso_serial *serial)
{
	unsigned long flags;

	spin_lock_irqsave(&serial_table_lock, flags);
	if (serial)
		serial_table[index] = serial->parent;
	else
		serial_table[index] = NULL;
	serial_table[serial->minor] = NULL;
	spin_unlock_irqrestore(&serial_table_lock, flags);
}

@@ -2243,6 +2242,7 @@ static int hso_stop_serial_device(struct hso_device *hso_dev)
static void hso_serial_tty_unregister(struct hso_serial *serial)
{
	tty_unregister_device(tty_drv, serial->minor);
	release_minor(serial);
}

static void hso_serial_common_free(struct hso_serial *serial)
@@ -2266,22 +2266,22 @@ static void hso_serial_common_free(struct hso_serial *serial)
static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
				    int rx_size, int tx_size)
{
	int minor;
	int i;

	tty_port_init(&serial->port);

	minor = get_free_serial_index();
	if (minor < 0)
		goto exit;
	if (obtain_minor(serial))
		goto exit2;

	/* register our minor number */
	serial->parent->dev = tty_port_register_device_attr(&serial->port,
			tty_drv, minor, &serial->parent->interface->dev,
			tty_drv, serial->minor, &serial->parent->interface->dev,
			serial->parent, hso_serial_dev_groups);
	if (IS_ERR(serial->parent->dev)) {
		release_minor(serial);
		goto exit2;
	}

	/* fill in specific data for later use */
	serial->minor = minor;
	serial->magic = HSO_SERIAL_MAGIC;
	spin_lock_init(&serial->serial_lock);
	serial->num_rx_urbs = num_urbs;
@@ -2323,6 +2323,7 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
	return 0;
exit:
	hso_serial_tty_unregister(serial);
exit2:
	hso_serial_common_free(serial);
	return -1;
}
@@ -2686,9 +2687,6 @@ static struct hso_device *hso_create_bulk_serial_device(

	serial->write_data = hso_std_serial_write_data;

	/* and record this serial */
	set_serial_by_index(serial->minor, serial);

	/* setup the proc dirs and files if needed */
	hso_log_port(hso_dev);

@@ -2745,9 +2743,6 @@ struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface,
	serial->shared_int->ref_count++;
	mutex_unlock(&serial->shared_int->shared_int_lock);

	/* and record this serial */
	set_serial_by_index(serial->minor, serial);

	/* setup the proc dirs and files if needed */
	hso_log_port(hso_dev);

@@ -3131,8 +3126,7 @@ static void hso_free_interface(struct usb_interface *interface)
			cancel_work_sync(&serial_table[i]->async_put_intf);
			cancel_work_sync(&serial_table[i]->async_get_intf);
			hso_serial_tty_unregister(serial);
			kref_put(&serial_table[i]->ref, hso_serial_ref_free);
			set_serial_by_index(i, NULL);
			kref_put(&serial->parent->ref, hso_serial_ref_free);
		}
	}