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

!11273 serial: core: check uartclk for zero to avoid divide by zero

parents 25aa773a d7a76316
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -862,6 +862,14 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
	new_flags = (__force upf_t)new_info->flags;
	old_custom_divisor = uport->custom_divisor;

	if (!(uport->flags & UPF_FIXED_PORT)) {
		unsigned int uartclk = new_info->baud_base * 16;
		/* check needs to be done here before other settings made */
		if (uartclk == 0) {
			retval = -EINVAL;
			goto exit;
		}
	}
	if (!capable(CAP_SYS_ADMIN)) {
		retval = -EPERM;
		if (change_irq || change_port ||