From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 EEA5237F8C4 for ; Thu, 13 Aug 2026 17:44:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786643075; cv=none; b=qoJ+PCLJkanjtDPEkEgBvQdg4oEk471bC3BPxxDEWRwZ3QjDUndoabZlfyAgbUmRb6WjM69P5FeLRImkg5Q/1lQ/FLiHsW7A3h2HjFlypNeVR+2xBLLEktree52kCJB8PUSaZg5UEgcfE98Vud7lJzL2NOWYlReaWh68LVuybLY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786643075; c=relaxed/simple; bh=HY/3y1F57XpjwQEPpDihUBWf2GBCrSsQ/kbYH1qIcPw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M1w4eW1NJao50TUxLN7n/HgRAfgHYX80zWX7/1Oqx2H0jJLCEPMgUlVB4yYoA8jxRIhan0UkBoiNUzr/vmZW6LUfxU16Z37BZC0UTCbx/V8CgLclGr0mkVf22YpwGldPbGiB9NvMlbQjfxXDMEEF5ppzqQP3ONR87gW2/iQVMrY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BrYcbarb; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BrYcbarb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786643072; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HM8zvcL/8EecJPDVQT6aSutYylxT/HBspErHsI6olAE=; b=BrYcbarbA6WMCTaQF0dCb90OjHno23x8Gtkn1FwILZjXb6Ytl89DEvC0j9Rgob26vK5FkF gLXE7gcHeND37l1i6YV4UuJ7ixS9Ea5A+wf3Fdly7xbOte9CPV8fdBWWiqlPKDvqJz1rjP Bnob8zgYtL3UOFdr7pt7Lpb8dJ3Ri8E= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-355-6hvQk1RBNW6t1v6PxmWfOg-1; Thu, 13 Aug 2026 13:44:28 -0400 X-MC-Unique: 6hvQk1RBNW6t1v6PxmWfOg-1 X-Mimecast-MFC-AGG-ID: 6hvQk1RBNW6t1v6PxmWfOg_1786643067 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D6E9F19560AE; Thu, 13 Aug 2026 17:44:26 +0000 (UTC) Received: from GoldenWind.redhat.com (unknown [10.22.80.207]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4CEED195608A; Thu, 13 Aug 2026 17:44:25 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org Cc: "Maarten Lankhorst" , "Simona Vetter" , "David Airlie" , "Thomas Zimmermann" , "Maxime Ripard" , "Danilo Krummrich" , "Lyude Paul" Subject: [PATCH v6 1/5] drm/nouveau: Fix cleanup bug in nouveau_drm_device_new() Date: Thu, 13 Aug 2026 13:42:52 -0400 Message-ID: <20260813174416.1812656-2-lyude@redhat.com> In-Reply-To: <20260813174416.1812656-1-lyude@redhat.com> References: <20260813174416.1812656-1-lyude@redhat.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 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Sashiko caught this while reviewing the patches for enabling atomic by default - if we fail to allocate the DRM device pointer, we'll attempt to free the error pointer that it returns rather than the actual struct. Let's fix this while we're at it. Signed-off-by: Lyude Paul --- V3: * Don't use devm, that will just break during unbind (Sashiko). V5: * Fix silly rebasing error * Go back to the old style of error handling since we're not using a second allocation for drm_driver anymore. drivers/gpu/drm/nouveau/nouveau_drm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 4d1ad718e09b7..a348115518ec4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -749,7 +749,8 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren drm->dev = drm_dev_alloc(drm_driver, parent); if (IS_ERR(drm->dev)) { ret = PTR_ERR(drm->dev); - goto done; + kfree(drm); + return ERR_PTR(ret); } drm->dev->dev_private = drm; -- 2.55.0