From patchwork Mon Mar 16 18:30:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2023 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773685890; bh=rXFU1gLR/wLZss0wLUAA3I8cg4H5KIK0CZubq5I3r/k=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Jnv094XbG3Lsm2WijWuvnGw+IHxqmG0x8COk76ujF0hBp+z5deIa9aeKobI6CCFuG MEAhSNc3wJKsGA/9utHW22llsnsJqkw739aJDKa8im6HQFTHF4Fz90pX1bsySw2ugf kEEATBPdFAr8BKLcfJvrjeWJlazatdyQmSqvsO2yyU6I/wz1QLyOz9hWolbxIPc61t +WKnGVtUvD/AxJjIVYCv/1yEugi08wdVbSxqlusp/BSF7rptECohwgfTgRg/khTktP 6oXq0iYHDC7XGWzEjlKbm269nHC7PqeR6YPE4HQLG+7zwUp/yF4if5vcVRW4QPKTNo OdF3iChki9B5A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DFAC86A09F for ; Mon, 16 Mar 2026 12:31:30 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id xjvHzf979ycD for ; Mon, 16 Mar 2026 12:31:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773685889; bh=rXFU1gLR/wLZss0wLUAA3I8cg4H5KIK0CZubq5I3r/k=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=IaS5Zo2CYneJvXQAQnQZGF6DnSqkT+aZRyV7DALONxYuNsNjPDhZu8ueM1f8Rs8Rc rddnjIhewFg6312QPtIzc5EFnFgpPX30O815qgreXgukrbsQoFSLPBaEK0wyr4s5VD PgSVqYvYhWD3m1Skgn2isdL0uQWyg8TkOSjPsXoxtffMSgyw3ry701EyAksG2v9zXu zEVMSVEcmBzr8H8otpW7PNPrHuHI6wUpp2JlVbI4ny8uKEfHgKc2i9TEz6Y3N2sJWC gekBV418TCb5wT7wK4w8Y1m5/w+bz4WicU5Q4xHum8q9t5yhmatTnkYj103JswwpoD SksMqpm5ghBFg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 128A86A0C5 for ; Mon, 16 Mar 2026 12:31:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773685882; bh=7xW69+YY5zTrDmJzqrV40+EMX3P0w7hwMTenXWvIDXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qjt7cgcQ0hbOEZxHQoNfJV1O53r9ytzW7PBGsqP6AZKCwICG2oOpn63VqvTQEvhzK NDkzl4eiky49aUUJHowdPbqpumvbXLBUSwrUADNkNxsxPl9kpEHUIqXyFBtROXBmQ3 j3vNXXxWwWEv/J0F3vQSBaaRuR2tbmoVn2+ueUNcFI1YCyxWN9heNAAVdbli3qmUK5 0SK1kKmBJ2EKrqITnJv99HjfNcAJye8grnF1dv1lovX1UhIgg05HnN3UmGPpv5VLyQ JfiwPMQEHPvGx+L82F4a5TFJwyXEumOyrQjscvD+3orAkrkPYHkFoAkLR59iXAJ3BL mQ62Ln8DqXyPA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C75766A0A6; Mon, 16 Mar 2026 12:31:22 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id MyOyYLKaJS-u; Mon, 16 Mar 2026 12:31:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773685881; bh=0uspIHMqwyIHz7d/O4cB+zzgQg3slb1HeCFl2dxbIlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=urFMGf91PZ0WCYszLhfmhYKDjSHBYNri83mOWloqqT8IRv+s5HyaMFcmL8v5iKAP7 BtOUTJmR5KkTUzvYSbf7UJnfAp6bETiQfQUmAXo5hQaXRn8sOwSP+ZzAe1xf1qlGSz cZowLmyVEh+jpCXvNgoSvnFnyT/Dvs/9Z8yTj56WwVG9wU1vq6tlwVT8CR7RTuXcBt e0Qf4vvc1Dgq5HINNzf0jM5FQH5l/26lB7omgQlJ91cHvc+CYXbuHZCtM9x0o+YP1a 20CJOs9azTr+tcOhxh3lXIqO0fCmDIUKhqX1jXBr253kDGn+OfewGCBYIB5DfH7jL0 xZQNbhpeY02Ig== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 89A576A07B; Mon, 16 Mar 2026 12:31:21 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 16 Mar 2026 12:30:35 -0600 Message-ID: <20260316183050.3855921-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260316183050.3855921-1-sjg@u-boot.org> References: <20260316183050.3855921-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KXSRZ7WN2XMJZJCQ5Q7BGK6PBHOJTTKM X-Message-ID-Hash: KXSRZ7WN2XMJZJCQ5Q7BGK6PBHOJTTKM X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/17] power: pmic: Fix register leak in I2C PMIC emulator List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The sandbox I2C PMIC emulator allocates a register buffer in its probe function but has no remove function to free it. Add a remove handler to free the buffer when the device is removed. Fixes: eb7387ae14ef ("sandbox: pmic: Correct i2c pmic emulator platdata method") Signed-off-by: Simon Glass --- drivers/power/pmic/i2c_pmic_emul.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/power/pmic/i2c_pmic_emul.c b/drivers/power/pmic/i2c_pmic_emul.c index 6e81b9c3427..dd0ec39ef48 100644 --- a/drivers/power/pmic/i2c_pmic_emul.c +++ b/drivers/power/pmic/i2c_pmic_emul.c @@ -146,6 +146,16 @@ static int sandbox_i2c_pmic_probe(struct udevice *emul) return 0; } +static int sandbox_i2c_pmic_remove(struct udevice *emul) +{ + struct sandbox_i2c_pmic_plat_data *plat = dev_get_plat(emul); + + free(plat->reg); + plat->reg = NULL; + + return 0; +} + struct dm_i2c_ops sandbox_i2c_pmic_emul_ops = { .xfer = sandbox_i2c_pmic_xfer, }; @@ -161,6 +171,7 @@ U_BOOT_DRIVER(sandbox_i2c_pmic_emul) = { .of_match = sandbox_i2c_pmic_ids, .of_to_plat = sandbox_i2c_pmic_of_to_plat, .probe = sandbox_i2c_pmic_probe, + .remove = sandbox_i2c_pmic_remove, .plat_auto = sizeof(struct sandbox_i2c_pmic_plat_data), .ops = &sandbox_i2c_pmic_emul_ops, };