From nobody Mon Jun 15 20:34:37 2026 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 EAB83279334 for ; Mon, 13 Apr 2026 16:08:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776096521; cv=none; b=sSDe7XjXNPdw1jk2Ehegl1SYMehfAZ58gSyoTewvW2tfmRgK50tUSSIE4PS3yVyA4UDDn+onuFLyRMXk7SzpC3EqWfo2Vae/J5sgi+lFBlcHxx/AktaZNN3EY+jovS9M6uaHmk4bDzbWM4SqpV/9TIlPwpHVejB1S1HHxKCHUBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776096521; c=relaxed/simple; bh=i0LSOgsQKGdynyiwg2vfAGjEbqP1yPutN9vD5tSugdA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Sf+nGe1YNi3GNKcMxIvZU3YH3Kxj6fir5gyQ0t7PtvuREax9mAYd1ycsI4TqiMnPh8NaJ5tqYEqqRfCQLaU88VikPsuWBMmgpJavnmKKbqEiai2h+Z+XpMsoVt6FSFIJsn/C9v2KedLs+s11LZHokYlXWqQfcJytT8meUR2lB4E= 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=Lt+fmGNp; arc=none smtp.client-ip=209.85.216.42 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="Lt+fmGNp" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-35d9f68d011so2946375a91.2 for ; Mon, 13 Apr 2026 09:08:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776096519; x=1776701319; 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; bh=l7gUt840lhpSP9dZOUr3XTpDxlvgtE9AKADPLBm/S/0=; b=Lt+fmGNpCDm+H1MxN0/se2Q5x+EsMymOBsB95Cg+3jYlYD9hCMDNWwdrZAPI5JE6NP JHVCG2D/qR22jDDvFucTfQOZNE2MgrSdvwhXteABo96udJNOPML+G5FYypr+gM8hzBUu BhhN379gwfPXRdkrDy+CYQ+3C9PbRFBZUQU3n+bDxHoG/4wqPOfmPSRUROXL9u1oBAH0 9eHsbO00ckGVw+4G3F2qy3Rpuv+Q2B3SDEo5ucw8HhOJ9MNqTrScg+YvbxMdzIV6a7+G XmsoLyyGSQ7skQYbfRnUX1adkGbmcebhwv59VWOTEFNp0MlyEPn+cbi4IS0+wUxdv3wO R7XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776096519; x=1776701319; 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; bh=l7gUt840lhpSP9dZOUr3XTpDxlvgtE9AKADPLBm/S/0=; b=r5n7HesNvpI4THMfbpFSFasN+Ct5bk0JOzy3+txaYKrGbvdbui/4sxlBhQk9GN12PG kekdzzj7JEyb71HjgSlABYEEBxN9a4o/LFaQapV74CXBLOV6EgKSiN3TA8e6V1wD3Svl scaOmkKhJq//GgAz2n7ZWv3pXDniJFUwA8Ki0eI37EhPv/GwvfnEktjDQQjdbEAB7uwS s/kZ9UMvl631r1jJHdd+j9OTES5HP+H/owRlsus4ibqtJx+Kykh+Xt6PM6+emCK5B7Nk yCtWq0huej1/jkJ7wAmgIjuXdrEytZYwbIQpXMqENj6ydHrfUXNFHG5QjiBPf+C6c4bN 4wAw== X-Forwarded-Encrypted: i=1; AFNElJ8jYvi1U7D/UV0FfQvVw6Sk0AWhQUdGzO12cjrkf83XKcg/hc5nVDMzGWjjykc57LEt90XNGIToOZIP2G4=@vger.kernel.org X-Gm-Message-State: AOJu0YxT0Ao0dNVP+DA+0O7UDKctxv8O0MuKHLRkTmJSt9kKgHRYEL2s LxO8J7WNpDgPU0wsdsQjnsJFOq0uBPCiErQ4LjdBLl0KuV4nsu/JTBM8 X-Gm-Gg: AeBDiesrb/5pFpMkBBwMjS8gCmm0RQkAjZH+WFJhmQ0GnCLuhzfx5EIwcaTg2qShZ1p 4G8N9XsQAwPyS1erOaVU9JkQu49Vt2+ybas6V1DMg7/dv6VOEIBzfCA9OfNcZbKrw0cxIstgwq1 5TKEQq/md0e8bot/f8HbOiadFok8z5b/e+MzIXBYxkXeoah1E2PZ0GyeF72avtUvztjXjFBH+gO YaxCu7b4FOA8fccI6fpCw0nHJhcP71GrQPh5BvHa6z24jNn71lMYWTb3BY/9j6QZlAXIbIBYsxz hcirhE54WO1Ig/+JO0ixAmn+jpefGPf66Cr1k4PeDWZPmbDihbKFMZlaoYQDitN9J4bzqtr0LO0 yDifc3VswZ8njVLf4M2RzFiuyILvPXM27p5F1gN+C2OFiZl1BhZQN72+Z/HD88H4IRs/w7r6CPS oHv+irP9GQulGvRglDDNHUBwf7ahWXDzCQGRfpot5lWQ== X-Received: by 2002:a17:90b:390f:b0:336:b60f:3936 with SMTP id 98e67ed59e1d1-35e42749271mr14031698a91.12.1776096519207; Mon, 13 Apr 2026 09:08:39 -0700 (PDT) Received: from lgs.. ([2409:893d:1188:142d:edd0:8593:d07a:ab64]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35fbc72ffe0sm2814476a91.2.2026.04.13.09.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 09:08:38 -0700 (PDT) From: Guangshuo Li To: Guangshuo Li , linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH] gpio: omap: fix reference leak on platform_device_register() failure Date: Tue, 14 Apr 2026 00:08:29 +0800 Message-ID: <20260413160829.3072589-1-lgs201920130244@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" omap_mpuio_init() ignores the return value of platform_device_register(&omap_mpuio_device). The call flow is: omap_mpuio_init() -> platform_device_register(&omap_mpuio_device) -> device_initialize(&omap_mpuio_device.dev) -> platform_device_add(&omap_mpuio_device) If platform_device_add() fails, omap_mpuio_init() continues without dropping the device reference acquired by device_initialize(), leading to a reference leak. The issue was identified by a static analysis tool I developed and confirmed by manual review. Fix this by calling platform_device_put() when platform_device_register() fails. Fixes: 730e5ebff40c8 ("gpio: omap: do not register driver in probe()") Cc: stable@vger.kernel.org Signed-off-by: Guangshuo Li --- drivers/gpio/gpio-omap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index e39723b5901b..841bef431c22 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -800,11 +800,15 @@ static struct platform_device omap_mpuio_device =3D { static inline void omap_mpuio_init(struct gpio_bank *bank) { static bool registered; + int ret; =20 platform_set_drvdata(&omap_mpuio_device, bank); if (!registered) { - (void)platform_device_register(&omap_mpuio_device); - registered =3D true; + ret =3D platform_device_register(&omap_mpuio_device); + if (ret) + platform_device_put(&omap_mpuio_device); + else + registered =3D true; } } =20 --=20 2.43.0