Showing error 943

User: Jiri Slaby
Error type: Leaving function in locked state
Error type description: Some lock is not unlocked on all paths of a function, so it is leaked
File location: drivers/spi/spi.c
Line in file: 700
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Entered: 2012-03-02 21:35:17 UTC


Source:

670        if ((n_tx + n_rx) > SPI_BUFSIZ)
671                return -EINVAL;
672
673        spi_message_init(&message);
674        memset(&x, 0, sizeof x);
675        x.len = n_tx + n_rx;
676        spi_message_add_tail(&x, &message);
677
678        /* ... unless someone else is using the pre-allocated buffer */
679        if (!mutex_trylock(&lock)) {
680                local_buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL);
681                if (!local_buf)
682                        return -ENOMEM;
683        } else
684                local_buf = buf;
685
686        memcpy(local_buf, txbuf, n_tx);
687        x.tx_buf = local_buf;
688        x.rx_buf = local_buf;
689
690        /* do the i/o */
691        status = spi_sync(spi, &message);
692        if (status == 0)
693                memcpy(rxbuf, x.rx_buf + n_tx, n_rx);
694
695        if (x.tx_buf == buf)
696                mutex_unlock(&lock);
697        else
698                kfree(local_buf);
699
700        return status;
701}
702EXPORT_SYMBOL_GPL(spi_write_then_read);
703
704/*-------------------------------------------------------------------------*/
705
706static int __init spi_init(void)
707{
708        int        status;
709
710        buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL);
Show full sources