{"id":2222729,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2222729/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-tegra/patch/20260413141328.2954939-1-lgs201920130244@gmail.com/","project":{"id":21,"url":"http://patchwork.ozlabs.org/api/1.2/projects/21/?format=json","name":"Linux Tegra Development","link_name":"linux-tegra","list_id":"linux-tegra.vger.kernel.org","list_email":"linux-tegra@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260413141328.2954939-1-lgs201920130244@gmail.com>","list_archive_url":null,"date":"2026-04-13T14:13:28","name":"[v2] gpu: host1x: Fix device reference leak in device_add() error path","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6474407519475ed79dd2c5db42af5b9d09198191","submitter":{"id":91722,"url":"http://patchwork.ozlabs.org/api/1.2/people/91722/?format=json","name":"Guangshuo Li","email":"lgs201920130244@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-tegra/patch/20260413141328.2954939-1-lgs201920130244@gmail.com/mbox/","series":[{"id":499712,"url":"http://patchwork.ozlabs.org/api/1.2/series/499712/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-tegra/list/?series=499712","date":"2026-04-13T14:13:28","name":"[v2] gpu: host1x: Fix device reference leak in device_add() error path","version":2,"mbox":"http://patchwork.ozlabs.org/series/499712/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2222729/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222729/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-tegra+bounces-13747-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-tegra@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=GBN90tUb;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-tegra+bounces-13747-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"GBN90tUb\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.214.182","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fvTsk4d3kz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 00:13:46 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 819B03005AA9\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 14:13:43 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id D50FE3D9029;\n\tMon, 13 Apr 2026 14:13:42 +0000 (UTC)","from mail-pl1-f182.google.com (mail-pl1-f182.google.com\n [209.85.214.182])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 86C0B3D8125\n\tfor <linux-tegra@vger.kernel.org>; Mon, 13 Apr 2026 14:13:41 +0000 (UTC)","by mail-pl1-f182.google.com with SMTP id\n d9443c01a7336-2ad21f437eeso25855805ad.0\n        for <linux-tegra@vger.kernel.org>;\n Mon, 13 Apr 2026 07:13:41 -0700 (PDT)","from lgs.. ([2409:893d:1188:142d:6c67:74e8:5200:1f39])\n        by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-2b2d4dd5cfasm144226695ad.18.2026.04.13.07.13.35\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Mon, 13 Apr 2026 07:13:40 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776089622; cv=none;\n b=kS2uFSN11J+JOk8rcKyId02S3o7as1mJ3iS6IKfqo3UIPFQ3Yr2QjebRolBNFsi5oAxnLJ+YOVbWBV4Say4F7Ivt/xMy1RG/OejzjJqjeFqrBdODr+8LxwJ7hidSZp+VWOlBvGK+oZGJvXVwfOcE4DJZdKcyKuS6gjb2mTz6NIg=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776089622; c=relaxed/simple;\n\tbh=5S3YAVKId+04a0qvuN0YFuWomUi+TppqBBWCt03upfc=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=chagq4c4xEQJ4CUpI+ibY0+TvyoXruw8TotloQAI9j8BB2F4vlj5ywLZZeCN3mHkWPf4KcBdTqfw4UOvirBr1IURh2TOq2ggaHu0qPgcFd99mQppDC6c5xexQst+b9M5ol6oux2nve9EFdMOH2hNXIpNanwNFunVe/MzfRseaRo=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=GBN90tUb; arc=none smtp.client-ip=209.85.214.182","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1776089621; x=1776694421;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:from:to:cc:subject:date:message-id:reply-to;\n        bh=Q+qqSEWuusa4ngNGb7Rrw9FBrzRc6uTBdINaFH/HdeE=;\n        b=GBN90tUbaSJDVDCerN87/RzUxkuYqEzHz5DWs2XPwWhyMX1QPasgpng/hxAeyFCpey\n         ngimKXmf/VkhzBu0j3SgtUr6PopDfksyUcIsSpyaD3Mw/jQ+1zCp6PBUS/yFsB4OHqwX\n         Dvf3lnSRahlVJGHIQ11rQRVAJ1KzPKhBFQB76EmP6iU3r3hG08DIvy/pALCXW+0jYFp9\n         xacD/ZsA34uVvaCi4p32JifjuoNeBvBaK1mZM1vjCv72zsUrPkUiyFuA3lTVhZ3d65Ar\n         hnn9M9TbL5SmTNtL4zg2dDSY1T1hq/F3rIDZ/Dv9pAPNZeq1ndXHoIUXF45P4HwC3OZf\n         pYaQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776089621; x=1776694421;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=Q+qqSEWuusa4ngNGb7Rrw9FBrzRc6uTBdINaFH/HdeE=;\n        b=A76s2j4MNUlYv4f2YJRNkK8g2uVsyrdCKg9qoQSc+3M8Y4mp70MfWDhgqw6SbKN/gN\n         9C70qmJ35LB2K4OOush42u4/p3sd8/lhCgQQAtvzJBlE3p9lg/+R2Pb4DkLYeIVLv+Pf\n         Gi2AGalrWgWmNO2sDql/yld8u20Pz4S4pye/y1VwJDY8rfvCPKnMb0ZINz3IOkgTzBz1\n         ykDuFnf60wQySfBl15X5rct7xaBV0xS1snSlTEkMSrIf1jzxDsgwMSl1xHJDtceOqFuv\n         OZ+8VYdgtIj47NyQKp2gs7U9QvlP3AxdCe2DUlWUyKnSaqBuBo2vA7UTcGyH2UGVlB7a\n         zUSg==","X-Forwarded-Encrypted":"i=1;\n AFNElJ+xg3N5FhCoygLG+bFm9cv7kR90utpGzzBsgE4apuH1G+3+8KYHwlUXpo+v0FmzGFfBCMPyPDsoU2E5vA==@vger.kernel.org","X-Gm-Message-State":"AOJu0Yz5u7mvBs96eKMdu/Azi9niw4n8j7ITaeBh9qZ5ssGbRIMjoTSe\n\tITfj95k3617gBHA2f/2IaRtDvbaNhRGicqBY/8kCFoIFc+3Q/rZZULaJ","X-Gm-Gg":"AeBDietovuYw9YczInJLrBTSDr9lIsw78TzauRy5957H3zvUPZ13+il7HUgB3lJiDTG\n\t+BHg41vmfOs2uwBBXK4QuZOVQLmOOrl+1GO9BWu33ZgKPpXWYbvL0j+rxKxSpnPvWfKb5CrUdgo\n\t+o4VjO1wS7mTdegN7ds6mgix45xmeMaD1sardoC6vInfDerw3zB7MqWMId5RasU3QcEwqHr5OOF\n\tPzcjv9pbYHqfth1+h9yv177lFeiyFnFVCOVfa7qVxZB9vsxPeFKhpashGpX62gcUoFu1Ct65t3/\n\tE18Blxjgfn8vGsmfLlh5e6Yla1jvha0hgO8VfkPuqlamToMCyMVIdcDikkpZRA20h2vCy0SVkfO\n\tkxX2P9DVAqlpwX6lxGyMNhtcx1lMckkm/xmbXCciZMSFCS6tF3appW7QnBGL3X5mG6S0Allx1+q\n\tVsyDVC0Rl7eA+sY4ShIrDYmYpGzNr6v4+5IMQsww+j7w==","X-Received":"by 2002:a17:902:e78e:b0:2b0:91e6:bc18 with SMTP id\n d9443c01a7336-2b2d5d0e8b6mr126999785ad.14.1776089620819;\n        Mon, 13 Apr 2026 07:13:40 -0700 (PDT)","From":"Guangshuo Li <lgs201920130244@gmail.com>","To":"Thierry Reding <thierry.reding@gmail.com>,\n\tMikko Perttunen <mperttunen@nvidia.com>,\n\tDavid Airlie <airlied@gmail.com>,\n\tSimona Vetter <simona@ffwll.ch>,\n\tGuangshuo Li <lgs201920130244@gmail.com>,\n\tVamsee Vardhan Thummala <vthummala@nvidia.com>,\n\tlinux-kernel@vger.kernel.org,\n\tdri-devel@lists.freedesktop.org,\n\tlinux-tegra@vger.kernel.org","Cc":"stable@vger.kernel.org","Subject":"[PATCH v2] gpu: host1x: Fix device reference leak in device_add()\n error path","Date":"Mon, 13 Apr 2026 22:13:28 +0800","Message-ID":"<20260413141328.2954939-1-lgs201920130244@gmail.com>","X-Mailer":"git-send-email 2.43.0","Precedence":"bulk","X-Mailing-List":"linux-tegra@vger.kernel.org","List-Id":"<linux-tegra.vger.kernel.org>","List-Subscribe":"<mailto:linux-tegra+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-tegra+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"After device_initialize(), the embedded struct device in struct\nhost1x_device should be released through the device core with\nput_device().\n\nIn host1x_device_add(), the empty-subdevice path calls\ndevice_add(&device->dev), but if that fails it only logs the error and\ncontinues without dropping the device reference. That leaks the\nreference held on the embedded struct device.\n\nThe issue was identified by a static analysis tool I developed and\nconfirmed by manual review.\n\nFix this by removing the device from host1x->devices and calling\nput_device() when device_add() fails.\n\nFixes: fab823d82ee50 (\"gpu: host1x: Allow loading tegra-drm without enabled engines\")\nCc: stable@vger.kernel.org\nSigned-off-by: Guangshuo Li <lgs201920130244@gmail.com>\n---\nv2:\n  - note that the issue was identified by my static analysis tool\n  - and confirmed by manual review\n\n drivers/firmware/edd.c   | 2 +-\n drivers/gpu/host1x/bus.c | 6 +++++-\n 2 files changed, 6 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c\nindex 55dec4eb2c00..82b326ce83ce 100644\n--- a/drivers/firmware/edd.c\n+++ b/drivers/firmware/edd.c\n@@ -748,7 +748,7 @@ edd_init(void)\n \n \t\trc = edd_device_register(edev, i);\n \t\tif (rc) {\n-\t\t\tkfree(edev);\n+\t\t\tkobject_put(&edev->kobj);\n \t\t\tgoto out;\n \t\t}\n \t\tedd_devices[i] = edev;\ndiff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c\nindex 723a80895cd4..63fe037c3b65 100644\n--- a/drivers/gpu/host1x/bus.c\n+++ b/drivers/gpu/host1x/bus.c\n@@ -477,8 +477,12 @@ static int host1x_device_add(struct host1x *host1x,\n \t */\n \tif (list_empty(&device->subdevs)) {\n \t\terr = device_add(&device->dev);\n-\t\tif (err < 0)\n+\t\tif (err < 0) {\n \t\t\tdev_err(&device->dev, \"failed to add device: %d\\n\", err);\n+\t\t\tlist_del(&device->list);\n+\t\t\tput_device(&device->dev);\n+\t\t\treturn err;\n+\t\t}\n \t\telse\n \t\t\tdevice->registered = true;\n \t}\n","prefixes":["v2"]}