OSDN Git Service

Do not dereference 'siw_crypto_shash' before checking
authorBernard Metzler <bmt@zurich.ibm.com>
Sat, 27 Jul 2019 10:38:32 +0000 (12:38 +0200)
committerDoug Ledford <dledford@redhat.com>
Mon, 29 Jul 2019 17:35:05 +0000 (13:35 -0400)
Reported-by: "Dan Carpenter" <dan.carpenter@oracle.com>
Fixes: f29dd55b0236 ("rdma/siw: queue pair methods")
Link: https://lore.kernel.org/r/OF61E386ED.49A73798-ON00258444.003BD6A6-00258444.003CC8D9@notes.na.collabserv.com
Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/sw/siw/siw_qp.c

index 11383d9..e27bd5b 100644 (file)
@@ -220,12 +220,14 @@ static int siw_qp_enable_crc(struct siw_qp *qp)
 {
        struct siw_rx_stream *c_rx = &qp->rx_stream;
        struct siw_iwarp_tx *c_tx = &qp->tx_ctx;
-       int size = crypto_shash_descsize(siw_crypto_shash) +
-                       sizeof(struct shash_desc);
+       int size;
 
        if (siw_crypto_shash == NULL)
                return -ENOENT;
 
+       size = crypto_shash_descsize(siw_crypto_shash) +
+               sizeof(struct shash_desc);
+
        c_tx->mpa_crc_hd = kzalloc(size, GFP_KERNEL);
        c_rx->mpa_crc_hd = kzalloc(size, GFP_KERNEL);
        if (!c_tx->mpa_crc_hd || !c_rx->mpa_crc_hd) {