lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Sun,  3 Dec 2023 01:12:08 -0800
From:   Haoran Liu <liuhaoran14@....com>
To:     andi.shyti@...nel.org
Cc:     linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
        Haoran Liu <liuhaoran14@....com>
Subject: [PATCH] [i2c] viperboard: Add error handling in vprbrd_i2c_probe

This patch introduces improved error handling for the i2c_add_adapter.
The necessity for this enhancement was identified through static analysis,
revealing that the function previously did not properly manage potential
failures of i2c_add_adapter. Prior to this patch, a failure in
i2c_add_adapter could result in partial initialization of the I2C adapter,
leading to unstable operation.

Although the error addressed by this patch may not occur in the current
environment, I still suggest implementing these error handling routines
if the function is not highly time-sensitive. As the environment evolves
or the code gets reused in different contexts, there's a possibility that
these errors might occur. In case you find this addition unnecessary, I
completely understand and respect your perspective. My intention was to
enhance the robustness of the code, but I acknowledge that practical
considerations and current functionality might not warrant this change
at this point.

Signed-off-by: Haoran Liu <liuhaoran14@....com>
---
 drivers/i2c/busses/i2c-viperboard.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-viperboard.c b/drivers/i2c/busses/i2c-viperboard.c
index 9e153b5b0e8e..13a07290ecf6 100644
--- a/drivers/i2c/busses/i2c-viperboard.c
+++ b/drivers/i2c/busses/i2c-viperboard.c
@@ -400,7 +400,11 @@ static int vprbrd_i2c_probe(struct platform_device *pdev)
 	vb_i2c->i2c.dev.parent = &pdev->dev;
 
 	/* attach to i2c layer */
-	i2c_add_adapter(&vb_i2c->i2c);
+	ret = i2c_add_adapter(&vb_i2c->i2c);
+	if (ret) {
+		dev_err(&pdev->dev, "i2c_add_adapter failed: %d\n", ret);
+		return ret;
+	}
 
 	platform_set_drvdata(pdev, vb_i2c);
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ