From patchwork Wed Aug 21 22:51:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 821619 Received: from maynard.decadent.org.uk (maynard.decadent.org.uk [65.21.191.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E5DC1494AD for ; Wed, 21 Aug 2024 23:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.21.191.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724281863; cv=none; b=tT1SU3Q7FS9VumMQlJs7A56sWfXdZtqsSxZn2RV6EiGP1joMTQXoyH7SolRd0u2neyv6QGsVE98o+F+oFS47+x5FNOOUemqcyCflgKalBHwmeVdGVEdFR1nl9Co9zSoddYKoXRj2uikvZk2QMbPROhPiKE4oEla2gxFTVO5iFVQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724281863; c=relaxed/simple; bh=9VBaL92c70s2HomVB+5Lnd8xoumFMjj+d/tq9KYHnb0=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=AHUnqHEeOVqh97742Hhs+lfwHjn7zNCbhVpLqw2JGvhPAFI7Mdh40n2pwZrKfR/GNV4wP4lEFbNGQ0D6ABn2qRww5BgG2xgiAbFyNBwMjKEXwSJSd8RBDWZAKsTYfqXZUgS4nSC+Id4nvjFN5DAHkjVOVhF+jT3i16N3TyMAar0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=decadent.org.uk; arc=none smtp.client-ip=65.21.191.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=decadent.org.uk Received: from [2a02:1810:1d14:e000:db6f:81d2:6624:c91c] (helo=deadeye) by maynard with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sguB6-005CZe-0y; Wed, 21 Aug 2024 22:51:43 +0000 Received: from ben by deadeye with local (Exim 4.98) (envelope-from ) id 1sguB4-00000003XOq-162O; Thu, 22 Aug 2024 00:51:42 +0200 Date: Thu, 22 Aug 2024 00:51:42 +0200 From: Ben Hutchings To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: Adaptec OEM Raid Solutions , linux-scsi@vger.kernel.org Subject: [PATCH] aacraid: Fix double-free on probe failure Message-ID: Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-SA-Exim-Connect-IP: 2a02:1810:1d14:e000:db6f:81d2:6624:c91c X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on maynard); SAEximRunCond expanded to false aac_probe_one() calls hardware-specific init functions through the aac_driver_ident::init pointer, all of which eventually call down to aac_init_adapter(). If aac_init_adapter() fails after allocating memory for aac_dev::queues, it frees the memory but does not clear that member. After the hardware-specific init function returns an error, aac_probe_one() goes down an error path that frees the memory pointed to by aac_dev::queues, resulting.in a double-free. Reported-by: Michael Gordon References: https://bugs.debian.org/1075855 Fixes: 8e0c5ebde82b ("[SCSI] aacraid: Newer adapter communication iterface support") Signed-off-by: Ben Hutchings --- drivers/scsi/aacraid/comminit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index bd99c5492b7d..0f64b0244303 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -642,6 +642,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) if (aac_comm_init(dev)<0){ kfree(dev->queues); + dev->queues = NULL; return NULL; } /* @@ -649,6 +650,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) */ if (aac_fib_setup(dev) < 0) { kfree(dev->queues); + dev->queues = NULL; return NULL; }