spi: dynamycally allocated message initialization
authorEmiliano Ingrassia <ingrassia@epigenesys.com>
Tue, 28 Mar 2017 07:49:29 +0000 (09:49 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 29 Mar 2017 10:40:39 +0000 (11:40 +0100)
Invoke the proper function while initializing
a dynamically allocated spi_message to avoid
NULL pointer dereference during resources deallocation.

Signed-off-by: Emiliano Ingrassia <ingrassia@epigenesys.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/linux/spi/spi.h

index 75c6bd0ac605b2024509985214cdc3d451c6ab53..3b0070695375916c4ebaa67f59cf4284e95e18e6 100644 (file)
@@ -891,7 +891,7 @@ static inline struct spi_message *spi_message_alloc(unsigned ntrans, gfp_t flags
                unsigned i;
                struct spi_transfer *t = (struct spi_transfer *)(m + 1);
 
-               INIT_LIST_HEAD(&m->transfers);
+               spi_message_init_no_memset(m);
                for (i = 0; i < ntrans; i++, t++)
                        spi_message_add_tail(t, m);
        }