Do not dereference 'siw_crypto_shash' before checking

Reported-by: "Dan Carpenter" <dan.carpenter@oracle.com>
Fixes: f29dd55b02 ("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>
This commit is contained in:
Bernard Metzler 2019-07-27 12:38:32 +02:00 коммит произвёл Doug Ledford
Родитель 15fe6a8dcc
Коммит 708637e65a
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -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) {