Fixed possible memory leaks in the Line Discipline and Line Markings messages
authorTom Knot <tomasknot@gmail.com>
Wed, 7 Mar 2018 10:19:59 +0000 (11:19 +0100)
committerTom Knot <tomasknot@gmail.com>
Wed, 7 Mar 2018 10:19:59 +0000 (11:19 +0100)
modules/unipi/src/unipi_uart.c

index ed549f03a27f7cf681749d5b06283253a3469e02..095551973e2cf7776b0e8f66eb2e668efa4a83f3 100644 (file)
@@ -78,12 +78,16 @@ int neuronspi_uart_ioctl (struct uart_port *port, unsigned int ioctl_code, unsig
                printk(KERN_INFO "NEURONSPI: IOCTL 0x5480\n");
                write_length = neuronspi_spi_compose_single_register_write(NEURONSPI_UART_TIMEOUT_REGISTER, &inp_buf, &outp_buf, (ioctl_arg * 1000000) / n_port->baud);
                neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 25, 1);
+               kfree(inp_buf);
+               kfree(outp_buf);
                return 1;
        }
        case 0x5481: {
                printk(KERN_INFO "NEURONSPI: IOCTL 0x5481\n");
                write_length = neuronspi_spi_compose_single_register_write(NEURONSPI_UART_TIMEOUT_REGISTER, &inp_buf, &outp_buf, ioctl_arg);
                neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 25, 1);
+               kfree(inp_buf);
+               kfree(outp_buf);
                return 1;
        }
        default: {
@@ -105,6 +109,8 @@ void neuronspi_uart_set_parmrk(struct uart_port *port, int to)
        printk(KERN_INFO "NEURONSPI: SET PARMRK to %d\n", to);
        write_length = neuronspi_spi_compose_single_register_write(NEURONSPI_UART_IFLAGS_REGISTER, &inp_buf, &outp_buf, to);
        neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 25, 1);
+       kfree(inp_buf);
+       kfree(outp_buf);
 }
 
 void neuronspi_uart_set_ldisc(struct uart_port *port, struct ktermios *kterm)
@@ -120,6 +126,8 @@ void neuronspi_uart_set_ldisc(struct uart_port *port, struct ktermios *kterm)
        printk(KERN_INFO "NEURONSPI: PROFIBUS discipline set\n");
        write_length = neuronspi_spi_compose_single_register_write(NEURONSPI_UART_LDISC_REGISTER, &inp_buf, &outp_buf, kterm->c_line);
        neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 25, 1);
+       kfree(inp_buf);
+       kfree(outp_buf);
 }
 
 void neuronspi_uart_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old)