From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 768B7282F10 for ; Fri, 7 Aug 2026 18:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786128633; cv=none; b=aCuiiNwUJr/LmMszTlwnu4KLn8u87OXPSuhytn7l0frj9kLjHffjyTQGZElWMR9CqRXlOhgLi7Ceg1LtAjSnCZee9fWBlKZ+QZZVcyG0yoUlgVTJbKZWzSa38opr3D9F0URP5NSs6f9uDxJDrBpkx4IyqdQSz5F+nUgYyU8bhpo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786128633; c=relaxed/simple; bh=2RBye3ZPr8nSEI/v54Gbh6xG9QzAw0hy5AkeJNg3XM4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nsDurX9qA3TA7ehmgnsOZhi37BiSx58FGUjzUWDUTb40sl89rUc3iBri9Xqa/f+Yl+nCtAmuGxgGZ17uy2vWLlYi9nD/XqCiAAQwDW1FJmsUxE2s+EMeOtwXLnzRCVMct48GfFqwN+KEBI7oIAEpOKiG2BxZ5L7Xbef6j14u7h0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=oTK/XhfY; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oTK/XhfY" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-84862b0d5aeso4347228b3a.2 for ; Fri, 07 Aug 2026 11:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786128632; x=1786733432; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=1YKYnkYiFPUfsXKn8ypCxMurlFacKXjrC3GxgCzJBQw=; b=oTK/XhfYXtG1CF243pyx9IU57/7pJseo2Z5zNNNOwzD4lp6dTV2IHVE+EpypqXNqGS yqbNX/PR6ewdMdP4NOvqiEOG8M+p75l9nJA6s8SCjlwACgWaBH9CvzmwCs5H80O24ajR w2GalAd69il9W/pDqkXAZCfh/QyM9D72CU6h0SQael0BpnqrLVDgc22LpgOJQ6pdjjKd O5RoMp5bOksp2o7fIlRTLWGWKX+/W4qEcsrSknwkx7ulLDlUU4BshYCtN65eWKveheCa 4gCllmVMGDGWNSU8pf3qWRGfBuoBZnkzvvtldAwdPZ67k/vfmzunIdsVbBCbdnDlAbBq XxNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786128632; x=1786733432; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1YKYnkYiFPUfsXKn8ypCxMurlFacKXjrC3GxgCzJBQw=; b=bb95eb1PTCLT2KrRpoI+j8La6EpBl76xT6dN5GUXPejx97Fc05udH9KBdEPaAHlMhC bHaTrBRAW8LZ9TUk9g12trwIl/AxaHd28EZHHjYnhbhFahgJemH6EOAWbhF1hp9nPWpe 5gEgwtWdZ1gSSO8pdoIZ8qUwyjHGo5D/jsUJPuxtAXl3RDTFD+OQlBX96tFmJBhTmRTy VvX9eh9RoEaMWk0u4hm4VIHIpn2yutgqeSreumhYvXPbF76/BDRpbR6NHKNPmy90CzFo SSlZ+1qRGbNC0VMr1BPzI/k4PLy+jHIJmsJ5VMm8ksfWClICFKaZiP025zZiCFVdss5v WTmQ== X-Forwarded-Encrypted: i=1; AHgh+Rp33neCryJKZivTWxjEsR7UkUmK8mvy/dH7IWlWddg5nAd9PRVk3RP7GMfq5FTZeOL0wrA3yL6u8paSGnM=@vger.kernel.org X-Gm-Message-State: AOJu0YzEUEV/F38tl3mqGL6W2gnMjlTJVW9kNRMn/ReU6+RT6XYwa28e aGyKxmCyqhhVxI+DDdEAMnM76unMYwvNvOmjPCBoq32Nm9d3BgBgdD7s X-Gm-Gg: AR+sD1186uot+t8RyrlWlhIIi8yzjQOXgVsOHwgwecPBSbqUfbtp+F4sLHorE4gr9hI Sv+W6VJCScW32l4QKkGyQjoH1uUaFbKG+oUcNGOPzYz1pik7POVXmagredCuOFNZ03RgwR+qXqA dwgDvMgEv1lN0tkdMTG827KFSb27silP90R1mjbdRsOUj9ZzFMz8OWrSf5twdjUSdiJG9K4K8dH OMn+R0kMVQleA7wTGFQqm51vsJdUFXDMGH3YD8EuCj/zkTaONJleZSBKZgIty24gnS8UYlF9wfY G1GnBV8ilGCycJe1WdyDRLZJLqdMxtfaZq9gqcuNaAKNFzjEphps7UmVysJLdGImuQzBuMEY9QQ 7f5OoAGQinu/ifB2h4d1xrbbtDBNXGh0WnYq/FxrPLqPzYY7XPsRWjapomXFlvHs+QFQ2j6nEl7 ubOV6kyVtwq5lCvJoQPYA0zDLdoTKF6qrXvmIiYqyrTVAgpqK3aPDoiQKsVRUuvf90MAqi13LMU I/ajs8eI0Id3vsSDlWrDmCAhJBiJs0GFYgv+m4qsE+7kwKf383p7lWHeutLp4z94tbbbzQ= X-Received: by 2002:a05:6a00:2d8f:b0:84c:4d9a:ae42 with SMTP id d2e1a72fcca58-84f2e00ea99mr25144376b3a.27.1786128631692; Fri, 07 Aug 2026 11:50:31 -0700 (PDT) Received: from bloom.localdomain ([2604:3d09:178e:e100::6868]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84f5a52060dsm1500361b3a.38.2026.08.07.11.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 11:50:31 -0700 (PDT) From: Ivy Lopez To: James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: viro@zeniv.linux.org.uk, axboe@kernel.dk, bvanassche@acm.org, ching2048@areca.com.tw, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Ivy Lopez Subject: [PATCH] scsi: arcmsr: fix DMA memory and IO queue leak on arcmsr_alloc_ccb_pool() failure Date: Fri, 7 Aug 2026 12:50:18 -0600 Message-ID: <20260807185018.80661-1-skunkolee@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If arcmsr_alloc_ccb_pool() fails in arcmsr_probe(), the error path jumps directly to unmap_pci_region, bypassing the free_ccb_pool label entirely. This leaks the CCB pool DMA allocation (acb->dma_coherent) whenever arcmsr_alloc_ccb_pool() fails after successfully allocating it, e.g. when the later arcmsr_alloc_xor_buffer() call fails. For ACB_ADAPTER_TYPE_F adapters specifically, the IO queue allocated earlier by arcmsr_alloc_io_queue() is also never freed on this path: other adapter types free their IO queue before calling arcmsr_alloc_ccb_pool() (since its space is folded into the CCB pool's own allocation), but type F does not, so it remains allocated and leaked if arcmsr_alloc_ccb_pool() subsequently fails. Fix this by routing arcmsr_alloc_ccb_pool() failure through the existing free_ccb_pool label, and explicitly freeing the IO queue for type F adapters beforehand. arcmsr_free_ccb_pool() is safe to call here regardless of how far arcmsr_alloc_ccb_pool() got: dma_free_coherent() is a no-op on a NULL address, and acb is zero-initialized via scsi_host_alloc()'s kzalloc(), so acb->dma_coherent and acb->xor_mega are both safely zero if arcmsr_alloc_ccb_pool() failed before setting them. Found via review feedback on a related fix (commit afa04c2998e4, "scsi: arcmsr: fix NULL deref on dma_alloc_coherent() failure in arcmsr_alloc_xor_buffer()"). Signed-off-by: Ivy Lopez Cc: ching Huang --- drivers/scsi/arcmsr/arcmsr_hba.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 40407b281839..d8e56d7b1906 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -1150,7 +1150,9 @@ static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id) arcmsr_free_io_queue(acb); error = arcmsr_alloc_ccb_pool(acb); if(error){ - goto unmap_pci_region; + if (acb->adapter_type == ACB_ADAPTER_TYPE_F) + arcmsr_free_io_queue(acb); + goto free_ccb_pool; } error = scsi_add_host(host, &pdev->dev); if(error){ -- 2.55.0