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

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

parents 0ced0bec 45b8fbbd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -850,6 +850,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 ||