From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 12B522580F2 for ; Tue, 23 Jun 2026 08:56:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782204972; cv=none; b=YnrCNFAeWEZaKdm3GGFSnzPhSsAXlqu075jlzU+j6S8OlbpU+EfBl/I0k6A2QgmEnwVDxEfrROwZn4Uqo2PArYDFvSxPENhnbfrg479TOTIcSYumBI5pKIWUJKK+PDdxTZgVDo6xatnqqm34bP+NO5DBKTHe7JWJEXC2UpG5GFQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782204972; c=relaxed/simple; bh=CMcXu7V7pt6MkhcND7t8Lz5xUFfOiEiSLiabhpjPmFk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nTj/F+g3Vl7OqDQDA6+AdZoY9Eesn/6f5T508NTXf36p00iiRlH+fiJs1FMdztZRt1PMAUNF7dvReUI8ycPm+QjqamMV+uL7ydIHiDLcT3ntasFJvukiMIifLteIW+mnLK2XbdZmk3AwQeD0joKskC46F1XLrhJagZCU5tvrcrw= 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=mpJbqobU; arc=none smtp.client-ip=209.85.210.175 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="mpJbqobU" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-845537740ddso2063566b3a.0 for ; Tue, 23 Jun 2026 01:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782204970; x=1782809770; 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=qoN/N/zV0mOtK+wxHpTPr+tV86a/2egova16++2Y83E=; b=mpJbqobURgpfnuuNoa27Q6zhfr5UycklTvO2FJHO0mLRZ0rN5XjLujSWOEX3+WwEGN QLOJ5IV30s83GHzqNUwFJQqQf1rau9AZ2lB0V1gS81sg3XpbH+L++EqrQeuiZk927V0Q MewFx1adixRqh4sG7zjyFRauP/9mtE1OqhYK9ksxFMoF9XORnHAzI3vfMAFfXPuWmrlI hM/N/Sbp+8ex1vXWoSmIOSFVi9F1HDqnM6My1Z2/BTShF1P7CC6kIzYmBrXvUmKIYKKZ tfsSqRmFaDtNpP+xEqftoySa0qktO0OFppddwkS9hg96G0RVtx46vkgr0TawBSRYsy+a +sgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782204970; x=1782809770; 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=qoN/N/zV0mOtK+wxHpTPr+tV86a/2egova16++2Y83E=; b=CEXU7WgZ+Fc68g0zCuXCYQ5i3u6+t50Tyys59GATKCvIz39V/nBkY1CK8zzW5m0rME vXNvpzsmwg8qFYE33u/BidRE2qwimk5JfFRGJBPySDdnprnc5fU6Od57UYqm57lbeN0b 4TQkgSwyTaF8OGbBOU9O1/+yEOu6do8oPG3WP7hi0mRVhG9QxOMEuQv4Ziw48xnyBMna cxHkoIA62RQTOJ6ulLPnJlTYu8GuEsPz6JfADF9fdkLWp4Zp3F0kVcy2ICqyGpo3xz5W z2YtpAdyM9rNTfLVPQe8lazTUAzmFuPxMPjw6gVkMehEwGCYsHJU64zdk32Z+rCPG+AB Fyxw== X-Forwarded-Encrypted: i=1; AFNElJ98zgOqDOE79SOscZOw858erWjGvxLBNAReDyjjtCg25gbX4oDwN6ptedsAbkzHDS2WVYF51/uiL3iFJaM=@vger.kernel.org X-Gm-Message-State: AOJu0YzMPc1uaEk8tGVbic5qHDPzqJODd9NiGNGHCZ3LIWpNKJsGUCLZ J5f6iy2t9dt/hsTiXyYMnrlxuG3TDdkJDvNtJgyzyBWjBtQm5S4dKBA= X-Gm-Gg: AfdE7cm30NvmpGwbcwXOYnuNsfBP1pkKBsl1Yz78q7ddLfB8Kju9FIdXSgZVfcmHJqy 5a3YUdoI7GreiM0fjPgPltiv+HwbHu5hwkULXBMfsqqt/JtwSu9g3ESKb7CB0XeKv8+ehjH4V02 rkvuAN32t48XR84JneSRcsWvxFUeJp0gG+BxZGqBdtsncdi5cINNXz3qtaSd5RK39hg+ptA/WrE X2q/iDcag3+0gmQrR1tYy09gQCx+YM8iY/M5jzLdGZ+i0ReCIqeFl9FSV352O9x2/BxsEoo+tTJ zIa0xSU/ss7tY7hSkLnSnu6r4oPIPro7cLWzcR1phJmY9LckhJ91Cpnn0pR1VQBClaviD14cCNp NsyJMm11hT0P08rXdx+G5rLlT2q65sP84JPK9XzAHlAYIWlrQl9CKZJNBjkpOK1B7/Dg579vU1g KwRI3lLUxzplSPt8OyT4eGZJF71ABj8oBLRBNhe6cfJn5UsdBytkpS+kXsEP0h51mq X-Received: by 2002:a05:6a00:cc8:b0:845:4b4b:8836 with SMTP id d2e1a72fcca58-8455088cec4mr18905236b3a.28.1782204970192; Tue, 23 Jun 2026 01:56:10 -0700 (PDT) Received: from localhost.localdomain ([14.5.152.27]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84571784ad0sm7757315b3a.24.2026.06.23.01.56.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Jun 2026 01:56:09 -0700 (PDT) From: Myeonghun Pak To: Arnd Bergmann , Greg Kroah-Hartman Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Myeonghun Pak , Ijae Kim Subject: [PATCH] char: xilinx_hwicap: unregister class on init errors Date: Tue, 23 Jun 2026 17:55:55 +0900 Message-ID: <20260623085604.89284-1-mhun512@gmail.com> X-Mailer: git-send-email 2.47.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit hwicap_module_init() registers icap_class before reserving the character-device region and registering the platform driver. If either of those later steps fails, the init path must undo the successful class registration before returning an error. Route the chrdev registration failure through a class unwind label, and let the platform-driver registration failure fall through the existing chrdev unwind before unregistering the class. The normal module exit path is unchanged. This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes: ef141a0bb0dc ("[POWERPC] Xilinx: hwicap driver") Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak --- drivers/char/xilinx_hwicap/xilinx_hwicap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index 34a345dc5e..9bb5fa642f 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c @@ -760,7 +760,7 @@ static int __init hwicap_module_init(void) HWICAP_DEVICES, DRIVER_NAME); if (retval < 0) - return retval; + goto failed_class; retval = platform_driver_register(&hwicap_platform_driver); if (retval) @@ -771,6 +771,9 @@ static int __init hwicap_module_init(void) failed: unregister_chrdev_region(devt, HWICAP_DEVICES); + failed_class: + class_unregister(&icap_class); + return retval; } -- 2.47.1