Message ID | 20210322120944.225643-2-its@irrelevant.dk |
---|---|
State | New |
Headers | show |
Series | hw/block/nvme: coverity fixes | expand |
On Mon, Mar 22, 2021 at 01:09:43PM +0100, Klaus Jensen wrote: >From: Klaus Jensen <k.jensen@samsung.com> > >If nvme_map_dptr() fails, nvme_dif_rw() will leak the bounce context. >Fix this by using the same error handling as everywhere else in the >function. > >Reported-by: Coverity (CID 1451080) >Fixes: 146f720c5563 ("hw/block/nvme: end-to-end data protection") >Signed-off-by: Klaus Jensen <k.jensen@samsung.com> >--- > hw/block/nvme-dif.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/hw/block/nvme-dif.c b/hw/block/nvme-dif.c >index 2038d724bda5..e6f04faafb5f 100644 >--- a/hw/block/nvme-dif.c >+++ b/hw/block/nvme-dif.c >@@ -432,7 +432,7 @@ uint16_t nvme_dif_rw(NvmeCtrl *n, NvmeRequest *req) > > status = nvme_map_dptr(n, &req->sg, mapped_len, &req->cmd); > if (status) { >- return status; >+ goto err; Looks good to me. > } > > ctx->data.bounce = g_malloc(len); >-- Reviewed-by: Gollu Appalanaidu <anaidu.gollu@samsung.com> >2.31.0 > >
diff --git a/hw/block/nvme-dif.c b/hw/block/nvme-dif.c index 2038d724bda5..e6f04faafb5f 100644 --- a/hw/block/nvme-dif.c +++ b/hw/block/nvme-dif.c @@ -432,7 +432,7 @@ uint16_t nvme_dif_rw(NvmeCtrl *n, NvmeRequest *req) status = nvme_map_dptr(n, &req->sg, mapped_len, &req->cmd); if (status) { - return status; + goto err; } ctx->data.bounce = g_malloc(len);