The patch 70556e24e18e: "drm: remove usage of drm_pci_alloc/free" leads to the following static checker warning: drivers/gpu/drm/drm_bufs.c:1090 drm_legacy_addbufs_pci() warn: inconsistent returns '&dev->struct_mutex'. Locked on : 988 Unlocked on: 938,944,951,959,973,1005,1042,1060,1090 Fix the return without cleanup by removing the early return and taking the original return path on allocation failure, including the intended unlocks. Signed-off-by: Joseph Kogut <joseph.kogut@xxxxxxxxx> --- drivers/gpu/drm/drm_bufs.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index 94bc1f6049c9..ea3ca81be9dd 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -984,17 +984,18 @@ int drm_legacy_addbufs_pci(struct drm_device *dev, while (entry->buf_count < count) { dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL); - if (!dmah) - return -ENOMEM; - - dmah->size = total; - dmah->vaddr = dma_alloc_coherent(dev->dev, - dmah->size, - &dmah->busaddr, - GFP_KERNEL); - if (!dmah->vaddr) { - kfree(dmah); - + if (dmah) { + dmah->size = total; + dmah->vaddr = dma_alloc_coherent(dev->dev, + dmah->size, + &dmah->busaddr, + GFP_KERNEL); + if (!dmah->vaddr) { + kfree(dmah); + dmah = NULL; + } + } + if (!dmah) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; entry->seg_count = count; -- 2.31.1