Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp467767rdb; Thu, 8 Feb 2024 10:53:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXuHEqurGjSocyyWK3/n2ltlNRF68/grHoxX1uSLdrcw8xrvWjW+HhIjdEL1HAoh94aiKJFVl4rz8nz+O9toiiKZD818Z/cuc81HMSrhQ== X-Google-Smtp-Source: AGHT+IElVyCoej9VWaFMkQ7/5Tbm/ri5vqCYNuVOMqo9Savrei7Kqefha0o3B23XBunFc4BH10m8 X-Received: by 2002:ad4:5962:0:b0:68c:68bd:b724 with SMTP id eq2-20020ad45962000000b0068c68bdb724mr111008qvb.4.1707418409794; Thu, 08 Feb 2024 10:53:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707418409; cv=pass; d=google.com; s=arc-20160816; b=0mM+/yJvkV2rdwdvYbOmJi40GINgFDW1btP4ap5qZ0+z1mhtN/2hY3EBKpTAHjHEyZ 6RwtHj02yrGRAFtJdxLKYgmxsC0sWbJT3cbREF2pdj1zmuz7Vwxl3/hyWf9iszbc9VL2 x6zSd1ajBsA4ZzQnLKs2yMnMtc13+3PtlyCtIllafEm+5xSB8LAklZ9h/z6yHPoDm3I8 n5DOOTiT5UkuCFW3/e8Mp4iBJxVsybcOiQOtCKSQ3ErVnon6CzDaqjmp74HnB4KnpFPi Es1vu2EH4LvrheEJKCFiGfWF281J2j3bNiXRCn1ClFLS9BxWQ4/q6pccF2Gx2zjSy+dR 1hFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TzzyzryuMk/YFmmwdL7/ClcZNi7RCUPErKB9A3hzeXw=; fh=q3CErA6cHX0W6r0sjnM3Bl3fBvHHqYcYWk2YzhU6Onk=; b=JkjwphuUjNkoJHLMYR+wnGl0Zytx6CPt3va4MYIXXoBDIghCEV4WWcP/LeWC9pdPaQ 3vPedelbvVxyY+goJyJN2Qgiu+z9Zuj1+xkiXiRjQ3sUtCA7XSycB+wLrwGsmi413WhJ k1fdiqV79+fDUWyV7h/SH/T4aDFmC6Ek8jz9Od/41Y5IhQZJuh46sojNni4Ap6dV+zir 0ObprP7iNtMeEoDVA2iY+R4ki6R8KnrdC+Nd51gPkf76iYxsrRynJLRujbYrvehdsch2 0tX0mxNDht7wYKeEtyjdrhjUxUU/bZ4kdUqfMxMJ/r7zchJN7Spgz8hHDhhcMrnPn9FV d5Zw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=p981bkJM; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-58566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58566-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com X-Forwarded-Encrypted: i=2; AJvYcCVd7Q1vCOxzjvTwm8cxT5f5xHZuMnZ7cbo7+drgT4zF/7dVHnrjbuU0CZfU1IAIcpPDtDD0Vt6i8yicmO7R+sV82jOfGoR+YookELRE9A== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a12-20020a0562140c2c00b0068c8519a28esi142993qvd.398.2024.02.08.10.53.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:53:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=p981bkJM; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-58566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58566-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8C2331C27984 for ; Thu, 8 Feb 2024 18:52:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5CC638DFA; Thu, 8 Feb 2024 18:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="p981bkJM" Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (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 B973328DA5; Thu, 8 Feb 2024 18:49:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.114.26.122 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418172; cv=none; b=KO4omEneIPdvFIJOt/SVrXvHXvKgEQ2VQmuLHrEFfGv0+MkqozkIgcH6FC63Jzzy3AtEz7IKUnIBgVsmACUnx26Fvy+jY4gwkmGzsS0gInJ3A4tELL+cXDPJ1aLTZiumlbFNyqjxAU7d72qJnEpbavEhNHOFz9TGPlV2dZgsRfM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418172; c=relaxed/simple; bh=C9trdHKUBo0wvYK5DBzsNfOU9QCkPyPGO5T7CJRyOKU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HGkDwYtwHHN0B91VZnZX8G4iGfX+kwQ0DU20XQNOtnS32p36VKtfdUJS5IdzaLwidYhu+uBmV4gDjN0/vnM29s673Vqm1ILUdGdkOEfCn1hHSqWbZm5UrVau1y3YPC12DbRsyM4C1RCHNYua9Pz5v9fkAXn8g/SJ9ac6KsdczWA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=p981bkJM; arc=none smtp.client-ip=167.114.26.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1707418163; bh=C9trdHKUBo0wvYK5DBzsNfOU9QCkPyPGO5T7CJRyOKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p981bkJMDqSSou5rOlzOfJadbQ5Y29NotpQj8i1nf+2MvVgxD1FBmL+l4Xm7YmzdU pVOSVM/g3dAlLka98d2D7RwQsxmwG0ztt/y7tiwbLnCbBg1xIMfMZO94OwRGQcJSPb oCvXA7vGn5txoQucNNDP9tTcibZl6yUWk91V3wI4h34U+qdeKKwoaP4EMRaCV9XKgF S42nnYMRLuRYjp1ifApVRqANDFYDEM92NpD/EJeqN1d+yPvkJOrTEc6AotGzGZx2U+ 6+NLjtZJNGG8sAZom+Btw0vTtF6/O0vjyrrF0zmTTKf6S58kysA1oIjzBQgjHVR/w7 0MBHTWE0Z4ToQ== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TW5cf5cnczXwf; Thu, 8 Feb 2024 13:49:22 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@lists.linux.dev, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org, Alasdair Kergon , Mike Snitzer , Mikulas Patocka Subject: [PATCH v4 01/12] nvdimm/pmem: Fix leak on dax_add_host() failure Date: Thu, 8 Feb 2024 13:49:02 -0500 Message-Id: <20240208184913.484340-2-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240208184913.484340-1-mathieu.desnoyers@efficios.com> References: <20240208184913.484340-1-mathieu.desnoyers@efficios.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Fix a leak on dax_add_host() error, where "goto out_cleanup_dax" is done before setting pmem->dax_dev, which therefore issues the two following calls on NULL pointers: out_cleanup_dax: kill_dax(pmem->dax_dev); put_dax(pmem->dax_dev); Signed-off-by: Mathieu Desnoyers Cc: Alasdair Kergon Cc: Mike Snitzer Cc: Mikulas Patocka Cc: Andrew Morton Cc: Linus Torvalds Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-arch@vger.kernel.org Cc: linux-cxl@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-xfs@vger.kernel.org Cc: dm-devel@lists.linux.dev Cc: nvdimm@lists.linux.dev --- drivers/nvdimm/pmem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 4e8fdcb3f1c8..9fe358090720 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -566,12 +566,11 @@ static int pmem_attach_disk(struct device *dev, set_dax_nomc(dax_dev); if (is_nvdimm_sync(nd_region)) set_dax_synchronous(dax_dev); + pmem->dax_dev = dax_dev; rc = dax_add_host(dax_dev, disk); if (rc) goto out_cleanup_dax; dax_write_cache(dax_dev, nvdimm_has_cache(nd_region)); - pmem->dax_dev = dax_dev; - rc = device_add_disk(dev, disk, pmem_attribute_groups); if (rc) goto out_remove_host; -- 2.39.2