* [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable
@ 2020-09-30 7:19 Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 02/12] globalvar: fix uninitialized read of variable when no nvvars exist Ahmad Fatoum
` (11 more replies)
0 siblings, 12 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:19 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
err is evaluated in a ternary condition on return, but if the while
loop is never entered, it is left uninitialized. Fix this.
Reported-by: clang-analyzer-10
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/hw_random/mxc-rngc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hw_random/mxc-rngc.c b/drivers/hw_random/mxc-rngc.c
index 3ed25aa61d05..075c20e43745 100644
--- a/drivers/hw_random/mxc-rngc.c
+++ b/drivers/hw_random/mxc-rngc.c
@@ -133,7 +133,7 @@ static int mxc_rngc_data_present(struct hwrng *rng)
static int mxc_rngc_read(struct hwrng *rng, void *buf, size_t max, bool wait)
{
struct mxc_rngc *rngc = container_of(rng, struct mxc_rngc, rng);
- unsigned int err;
+ unsigned int err = 0;
int count = 0;
u32 *data = buf;
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 02/12] globalvar: fix uninitialized read of variable when no nvvars exist
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
@ 2020-09-30 7:19 ` Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 03/12] commands: uimage: fix indeterminate exit code of command Ahmad Fatoum
` (10 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:19 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
When there are no nvvars, the function returns an uninitialized ret,
return 0 in this case instead.
Reported-by: clang-analyzer-10
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/globalvar.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/globalvar.c b/common/globalvar.c
index 09479da548f6..904acb94d730 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -674,7 +674,7 @@ int nvvar_save(void)
{
struct param_d *param;
const char *env = default_environment_path_get();
- int ret;
+ int ret = 0;
#define TMPDIR "/.env.tmp"
if (!nv_dirty || !env)
return 0;
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 03/12] commands: uimage: fix indeterminate exit code of command
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 02/12] globalvar: fix uninitialized read of variable when no nvvars exist Ahmad Fatoum
@ 2020-09-30 7:19 ` Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 04/12] watchdog: fix division-by-zero when clock rate == 0 Ahmad Fatoum
` (9 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:19 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Depending on passed options, uimage may never assign ret a value.
Fix this by returning COMMAND_SUCCESS by default.
Reported-by: clang-analyzer-10
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
commands/uimage.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/commands/uimage.c b/commands/uimage.c
index 982da7101aa7..fb4df780bdd0 100644
--- a/commands/uimage.c
+++ b/commands/uimage.c
@@ -19,7 +19,7 @@ static int uimage_flush(void *buf, unsigned int len)
static int do_uimage(int argc, char *argv[])
{
struct uimage_handle *handle;
- int ret;
+ int ret = 0;
int verify = 0;
int fd;
int opt;
@@ -84,7 +84,7 @@ static int do_uimage(int argc, char *argv[])
err:
uimage_close(handle);
- return ret ? 1 : 0;
+ return ret ? COMMAND_ERROR : COMMAND_SUCCESS;
}
BAREBOX_CMD_HELP_START(uimage)
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 04/12] watchdog: fix division-by-zero when clock rate == 0
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 02/12] globalvar: fix uninitialized read of variable when no nvvars exist Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 03/12] commands: uimage: fix indeterminate exit code of command Ahmad Fatoum
@ 2020-09-30 7:19 ` Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 05/12] net: usb: asix: propagate errors from MDIO accessors Ahmad Fatoum
` (8 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:19 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel, Ahmad Fatoum
Instead of storing the clk into the driver's device-specific private
data, just store the rate and make sure it's != 0 on probe.
This aligns us with what Linux does for the STM32 IWDG and DW WDT.
Reported-by: clang-analyzer-10
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/watchdog/ar9344_wdt.c | 21 ++++++++++++++-------
drivers/watchdog/dw_wdt.c | 19 ++++++++++++-------
drivers/watchdog/stm32_iwdg.c | 2 ++
3 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/drivers/watchdog/ar9344_wdt.c b/drivers/watchdog/ar9344_wdt.c
index 4615288631d6..c7cd552dc711 100644
--- a/drivers/watchdog/ar9344_wdt.c
+++ b/drivers/watchdog/ar9344_wdt.c
@@ -34,8 +34,8 @@
struct ar9344_wd {
struct watchdog wd;
void __iomem *base;
- struct clk *clk;
struct device_d *dev;
+ unsigned int rate;
};
static int ar9344_watchdog_set_timeout(struct watchdog *wd, unsigned timeout)
@@ -45,7 +45,7 @@ static int ar9344_watchdog_set_timeout(struct watchdog *wd, unsigned timeout)
if (timeout) {
ctrl = AR9344_WD_CTRL_ACTION_FCR;
- val = timeout * clk_get_rate(priv->clk);
+ val = timeout * priv->rate;
} else {
ctrl = AR9344_WD_CTRL_ACTION_NONE;
val = U32_MAX;
@@ -74,6 +74,7 @@ static int ar9344_wdt_probe(struct device_d *dev)
{
struct resource *iores;
struct ar9344_wd *priv;
+ struct clk *clk;
int ret;
priv = xzalloc(sizeof(struct ar9344_wd));
@@ -93,16 +94,22 @@ static int ar9344_wdt_probe(struct device_d *dev)
ar9344_watchdog_detect_reset_source(priv);
- priv->clk = clk_get(dev, NULL);
- if (IS_ERR(priv->clk)) {
+ clk = clk_get(dev, NULL);
+ if (IS_ERR(clk)) {
dev_err(dev, "could not get clk\n");
- ret = PTR_ERR(priv->clk);
+ ret = PTR_ERR(clk);
goto on_error;
}
- clk_enable(priv->clk);
+ clk_enable(clk);
- priv->wd.timeout_max = U32_MAX / clk_get_rate(priv->clk);
+ priv->rate = clk_get_rate(clk);
+ if (priv->rate == 0) {
+ ret = -EINVAL;
+ goto on_error;
+ }
+
+ priv->wd.timeout_max = U32_MAX / priv->rate;
ret = watchdog_register(&priv->wd);
if (ret)
diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index cb0d17e3610b..17771c712644 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -41,10 +41,10 @@
struct dw_wdt {
void __iomem *regs;
- struct clk *clk;
struct restart_handler restart;
struct watchdog wdd;
struct reset_control *rst;
+ unsigned int rate;
};
#define to_dw_wdt(wdd) container_of(wdd, struct dw_wdt, wdd)
@@ -55,7 +55,7 @@ static inline int dw_wdt_top_in_seconds(struct dw_wdt *dw_wdt, unsigned top)
* There are 16 possible timeout values in 0..15 where the number of
* cycles is 2 ^ (16 + i) and the watchdog counts down.
*/
- return (1U << (16 + top)) / clk_get_rate(dw_wdt->clk);
+ return (1U << (16 + top)) / dw_wdt->rate;
}
static int dw_wdt_start(struct watchdog *wdd)
@@ -134,6 +134,7 @@ static int dw_wdt_drv_probe(struct device_d *dev)
struct watchdog *wdd;
struct dw_wdt *dw_wdt;
struct resource *mem;
+ struct clk *clk;
int ret;
dw_wdt = xzalloc(sizeof(*dw_wdt));
@@ -143,11 +144,11 @@ static int dw_wdt_drv_probe(struct device_d *dev)
if (IS_ERR(dw_wdt->regs))
return PTR_ERR(dw_wdt->regs);
- dw_wdt->clk = clk_get(dev, NULL);
- if (IS_ERR(dw_wdt->clk))
- return PTR_ERR(dw_wdt->clk);
+ clk = clk_get(dev, NULL);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
- ret = clk_enable(dw_wdt->clk);
+ ret = clk_enable(clk);
if (ret)
return ret;
@@ -160,6 +161,10 @@ static int dw_wdt_drv_probe(struct device_d *dev)
wdd->hwdev = dev;
wdd->set_timeout = dw_wdt_set_timeout;
+ dw_wdt->rate = clk_get_rate(clk);
+ if (dw_wdt->rate == 0)
+ return -EINVAL;
+
ret = watchdog_register(wdd);
if (ret)
goto out_disable_clk;
@@ -179,7 +184,7 @@ static int dw_wdt_drv_probe(struct device_d *dev)
return 0;
out_disable_clk:
- clk_disable(dw_wdt->clk);
+ clk_disable(clk);
return ret;
}
diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
index 9e38f1a669f2..4d7a263b7e62 100644
--- a/drivers/watchdog/stm32_iwdg.c
+++ b/drivers/watchdog/stm32_iwdg.c
@@ -157,6 +157,8 @@ static int stm32_iwdg_probe(struct device_d *dev)
return ret;
wd->rate = clk_get_rate(clk);
+ if (wd->rate == 0)
+ return -EINVAL;
if (data->has_pclk) {
clk = clk_get(dev, "pclk");
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 05/12] net: usb: asix: propagate errors from MDIO accessors
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
` (2 preceding siblings ...)
2020-09-30 7:19 ` [PATCH 04/12] watchdog: fix division-by-zero when clock rate == 0 Ahmad Fatoum
@ 2020-09-30 7:19 ` Ahmad Fatoum
2020-09-30 7:24 ` [PATCH] fixup! " Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 06/12] digest: sha: remove no-op "erase" of automatic variables Ahmad Fatoum
` (7 subsequent siblings)
11 siblings, 1 reply; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:19 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The primitives asix_mdio_write and asix_mdio_read use return errors, but
are unchecked. Propagate them instead.
Reported-by: clang-analyzer-10
[afa: Untested on real hardware]
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/net/usb/asix.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 3ca27ff0270e..fc7063095b6c 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -252,11 +252,19 @@ static int asix_mdio_read(struct mii_bus *bus, int phy_id, int loc)
{
struct usbnet *dev = bus->priv;
__le16 res;
+ int ret;
+
+ ret = asix_set_sw_mii(dev);
+ if (ret)
+ return ret;
- asix_set_sw_mii(dev);
- asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id,
- (__u16)loc, 2, &res);
- asix_set_hw_mii(dev);
+ ret = asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, &res);
+ if (ret)
+ return ret;
+
+ ret = asix_set_hw_mii(dev);
+ if (ret)
+ return ret;
dev_dbg(&dev->edev.dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n",
phy_id, loc, le16_to_cpu(res));
@@ -268,15 +276,20 @@ static int asix_mdio_write(struct mii_bus *bus, int phy_id, int loc, u16 val)
{
struct usbnet *dev = bus->priv;
__le16 res = cpu_to_le16(val);
+ int ret;
dev_dbg(&dev->edev.dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n",
phy_id, loc, val);
- asix_set_sw_mii(dev);
- asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res);
- asix_set_hw_mii(dev);
+ ret = asix_set_sw_mii(dev);
+ if (ret)
+ return ret;
- return 0;
+ ret = asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res);
+ if (ret)
+ return ret;
+
+ return asix_set_hw_mii(dev);
}
static inline int asix_get_phy_addr(struct usbnet *dev)
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 06/12] digest: sha: remove no-op "erase" of automatic variables
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
` (3 preceding siblings ...)
2020-09-30 7:19 ` [PATCH 05/12] net: usb: asix: propagate errors from MDIO accessors Ahmad Fatoum
@ 2020-09-30 7:19 ` Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 07/12] common: memsize: eliminate dead store Ahmad Fatoum
` (6 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:19 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Some automatic variables are currently cleared as they may contain
"sensitive info". Any proper compiler would optimize away these
dead stores anyway, so just drop them.
Reported-by: clang-analyzer-10
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
crypto/sha2.c | 4 ----
crypto/sha4.c | 3 ---
2 files changed, 7 deletions(-)
diff --git a/crypto/sha2.c b/crypto/sha2.c
index 3947a09f41bb..013f5bb3b248 100644
--- a/crypto/sha2.c
+++ b/crypto/sha2.c
@@ -211,10 +211,6 @@ static void sha256_transform(u32 *state, const u8 *input)
state[0] += a; state[1] += b; state[2] += c; state[3] += d;
state[4] += e; state[5] += f; state[6] += g; state[7] += h;
-
- /* clear any sensitive info... */
- a = b = c = d = e = f = g = h = t1 = t2 = 0;
- memset(W, 0, 64 * sizeof(u32));
}
static int sha224_init(struct digest *desc)
diff --git a/crypto/sha4.c b/crypto/sha4.c
index aad8081fa5b7..a2e90c0a2cae 100644
--- a/crypto/sha4.c
+++ b/crypto/sha4.c
@@ -124,9 +124,6 @@ sha512_transform(u64 *state, const u8 *input)
state[0] += a; state[1] += b; state[2] += c; state[3] += d;
state[4] += e; state[5] += f; state[6] += g; state[7] += h;
-
- /* erase our data */
- a = b = c = d = e = f = g = h = t1 = t2 = 0;
}
static int
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 07/12] common: memsize: eliminate dead store
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
` (4 preceding siblings ...)
2020-09-30 7:19 ` [PATCH 06/12] digest: sha: remove no-op "erase" of automatic variables Ahmad Fatoum
@ 2020-09-30 7:20 ` Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 08/12] USB: musb: remove dead stores Ahmad Fatoum
` (5 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:20 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The assignment to val at this location serves no purpose, drop it to
reduce clutter.
Reported-by: clang-analyzer-10
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/memsize.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/memsize.c b/common/memsize.c
index 915ab87b340a..2fd2b7145759 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -58,7 +58,7 @@ long get_ram_size(volatile long *base, long maxsize)
*addr = 0;
sync ();
- if ((val = *addr) != 0) {
+ if (*addr != 0) {
/* Restore the original data before leaving the function.
*/
sync ();
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 08/12] USB: musb: remove dead stores
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
` (5 preceding siblings ...)
2020-09-30 7:20 ` [PATCH 07/12] common: memsize: eliminate dead store Ahmad Fatoum
@ 2020-09-30 7:20 ` Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 09/12] fs: squashfs: remove dead stores for xattr_id Ahmad Fatoum
` (4 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:20 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Reading the interrupt registers has a side-effect, so their value need
not be used for anythig. Storing it into a variable never read
obfuscates this however. Cast to (void) for clarity.
Reported-by: clang-analyzer-10
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/usb/musb/musb_core.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 9fdef8679b88..266663a9b0ec 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -330,7 +330,6 @@ void musb_load_testpacket(struct musb *musb)
static void musb_generic_disable(struct musb *musb)
{
void __iomem *mbase = musb->mregs;
- u16 temp;
/* disable interrupts */
musb_writeb(mbase, MUSB_INTRUSBE, 0);
@@ -343,9 +342,9 @@ static void musb_generic_disable(struct musb *musb)
musb_writeb(mbase, MUSB_DEVCTL, 0);
/* flush pending interrupts */
- temp = musb_readb(mbase, MUSB_INTRUSB);
- temp = musb_readw(mbase, MUSB_INTRTX);
- temp = musb_readw(mbase, MUSB_INTRRX);
+ (void)musb_readb(mbase, MUSB_INTRUSB);
+ (void)musb_readw(mbase, MUSB_INTRTX);
+ (void)musb_readw(mbase, MUSB_INTRRX);
}
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 09/12] fs: squashfs: remove dead stores for xattr_id
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
` (6 preceding siblings ...)
2020-09-30 7:20 ` [PATCH 08/12] USB: musb: remove dead stores Ahmad Fatoum
@ 2020-09-30 7:20 ` Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 10/12] reset: remove dead initialization Ahmad Fatoum
` (3 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:20 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
barebox doesn't do extended attributes in SquashFS. Remove the left-over
xattr_id that's never read.
Reported-by: clang-analyzer-10
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
fs/squashfs/inode.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
index 64155d47dbf4..f702f6c0a2d9 100644
--- a/fs/squashfs/inode.c
+++ b/fs/squashfs/inode.c
@@ -108,7 +108,6 @@ int squashfs_read_inode(struct inode *inode, long long ino)
int err, type, offset = SQUASHFS_INODE_OFFSET(ino);
union squashfs_inode squashfs_ino;
struct squashfs_base_inode *sqshb_ino = &squashfs_ino.base;
- int xattr_id = SQUASHFS_INVALID_XATTR;
TRACE("Entered squashfs_read_inode: %lld\n", ino);
@@ -197,7 +196,6 @@ int squashfs_read_inode(struct inode *inode, long long ino)
frag_offset = 0;
}
- xattr_id = le32_to_cpu(sqsh_ino->xattr);
inode->i_size = le64_to_cpu(sqsh_ino->file_size);
inode->i_op = &squashfs_inode_ops;
inode->i_mode |= S_IFREG;
@@ -249,7 +247,6 @@ int squashfs_read_inode(struct inode *inode, long long ino)
if (err < 0)
goto failed_read;
- xattr_id = le32_to_cpu(sqsh_ino->xattr);
inode->i_size = le32_to_cpu(sqsh_ino->file_size);
inode->i_op = &squashfs_dir_inode_ops;
inode->i_fop = &squashfs_dir_ops;
@@ -294,7 +291,6 @@ int squashfs_read_inode(struct inode *inode, long long ino)
&offset, sizeof(xattr));
if (err < 0)
goto failed_read;
- xattr_id = le32_to_cpu(xattr);
}
TRACE("Symbolic link inode %x:%x, start_block %llx, offset "
@@ -338,7 +334,6 @@ int squashfs_read_inode(struct inode *inode, long long ino)
inode->i_mode |= S_IFCHR;
else
inode->i_mode |= S_IFBLK;
- xattr_id = le32_to_cpu(sqsh_ino->xattr);
rdev = le32_to_cpu(sqsh_ino->rdev);
TRACE("Device inode %x:%x, rdev %x\n",
@@ -375,7 +370,6 @@ int squashfs_read_inode(struct inode *inode, long long ino)
inode->i_mode |= S_IFIFO;
else
inode->i_mode |= S_IFSOCK;
- xattr_id = le32_to_cpu(sqsh_ino->xattr);
break;
}
default:
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 10/12] reset: remove dead initialization
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
` (7 preceding siblings ...)
2020-09-30 7:20 ` [PATCH 09/12] fs: squashfs: remove dead stores for xattr_id Ahmad Fatoum
@ 2020-09-30 7:20 ` Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 11/12] sandbox: fix behavior with images >= 4G on 32-bit Ahmad Fatoum
` (2 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:20 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
rstc is never read before written, so just drop the initializer.
Reported-by: clang-analyzer-10
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/reset/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 99b9c806550c..26a54f21dff0 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -150,7 +150,7 @@ EXPORT_SYMBOL_GPL(reset_control_deassert);
static struct reset_control *of_reset_control_get(struct device_node *node,
const char *id)
{
- struct reset_control *rstc = ERR_PTR(-ENODEV);
+ struct reset_control *rstc;
struct reset_controller_dev *r, *rcdev;
struct of_phandle_args args;
int index = 0;
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 11/12] sandbox: fix behavior with images >= 4G on 32-bit
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
` (8 preceding siblings ...)
2020-09-30 7:20 ` [PATCH 10/12] reset: remove dead initialization Ahmad Fatoum
@ 2020-09-30 7:20 ` Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 12/12] blspec: fix dead assignment Ahmad Fatoum
2020-10-02 4:04 ` [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Sascha Hauer
11 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:20 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
hf->base may remain uninitialized if an image is > 4G, but sandbox
barebox is compiled for 32-bit. Fix this.
Reported-by: clang-analyzer-10
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/os/common.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 43ee95edb6e3..72bb35464f25 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -289,6 +289,7 @@ static int add_image(const char *_str, char *devname_template, int *devname_numb
hf->fd = fd;
hf->filename = filename;
hf->is_blockdev = blkdev;
+ hf->base = (unsigned long)MAP_FAILED;
if (fd < 0) {
perror("open");
@@ -311,15 +312,16 @@ static int add_image(const char *_str, char *devname_template, int *devname_numb
if (!cdev)
hf->is_blockdev = 1;
}
- if (hf->size <= SIZE_MAX)
+ if (hf->size <= SIZE_MAX) {
hf->base = (unsigned long)mmap(NULL, hf->size,
PROT_READ | (readonly ? 0 : PROT_WRITE),
MAP_SHARED, fd, 0);
- else
- printf("warning: %s: contiguous map failed\n", filename);
- if (hf->base == (unsigned long)MAP_FAILED)
- printf("warning: mmapping %s failed: %s\n", filename, strerror(errno));
+ if (hf->base == (unsigned long)MAP_FAILED)
+ printf("warning: mmapping %s failed: %s\n", filename, strerror(errno));
+ } else {
+ printf("warning: %s: contiguous map failed\n", filename);
+ }
if (blkdev && hf->size % 512 != 0) {
printf("warning: registering %s as block device failed: invalid block size\n",
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 12/12] blspec: fix dead assignment
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
` (9 preceding siblings ...)
2020-09-30 7:20 ` [PATCH 11/12] sandbox: fix behavior with images >= 4G on 32-bit Ahmad Fatoum
@ 2020-09-30 7:20 ` Ahmad Fatoum
2020-10-02 4:04 ` [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Sascha Hauer
11 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:20 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
cdev is assigned for each loop iteration and consumed inside.
The initial value is never read, so drop it.
Reported-by: clang-analyzer-10
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/blspec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/blspec.c b/common/blspec.c
index 9499d32477d9..a07343f4274e 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -766,7 +766,7 @@ int blspec_scan_devices(struct bootentries *bootentries)
device_detect(dev);
for_each_block_device(bdev) {
- struct cdev *cdev = &bdev->cdev;
+ struct cdev *cdev;
list_for_each_entry(cdev, &bdev->dev->cdevs, devices_list) {
ret = blspec_scan_cdev(bootentries, cdev);
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH] fixup! net: usb: asix: propagate errors from MDIO accessors
2020-09-30 7:19 ` [PATCH 05/12] net: usb: asix: propagate errors from MDIO accessors Ahmad Fatoum
@ 2020-09-30 7:24 ` Ahmad Fatoum
2020-10-02 4:04 ` Sascha Hauer
0 siblings, 1 reply; 15+ messages in thread
From: Ahmad Fatoum @ 2020-09-30 7:24 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
usb_control_msg doesn't (always) return 0 on success.
Adjust the error checks to explicitly check for negative return values
instead.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Should probably be tested before applying. Sascha, can you easily do
this?
---
drivers/net/usb/asix.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index fc7063095b6c..1140be9d1601 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -255,15 +255,15 @@ static int asix_mdio_read(struct mii_bus *bus, int phy_id, int loc)
int ret;
ret = asix_set_sw_mii(dev);
- if (ret)
+ if (ret < 0)
return ret;
ret = asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, &res);
- if (ret)
+ if (ret < 0)
return ret;
ret = asix_set_hw_mii(dev);
- if (ret)
+ if (ret < 0)
return ret;
dev_dbg(&dev->edev.dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n",
@@ -282,14 +282,18 @@ static int asix_mdio_write(struct mii_bus *bus, int phy_id, int loc, u16 val)
phy_id, loc, val);
ret = asix_set_sw_mii(dev);
- if (ret)
+ if (ret < 0)
return ret;
ret = asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res);
- if (ret)
+ if (ret < 0)
return ret;
- return asix_set_hw_mii(dev);
+ ret = asix_set_hw_mii(dev);
+ if (ret < 0)
+ return ret;
+
+ return 0;
}
static inline int asix_get_phy_addr(struct usbnet *dev)
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] fixup! net: usb: asix: propagate errors from MDIO accessors
2020-09-30 7:24 ` [PATCH] fixup! " Ahmad Fatoum
@ 2020-10-02 4:04 ` Sascha Hauer
0 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2020-10-02 4:04 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Wed, Sep 30, 2020 at 09:24:57AM +0200, Ahmad Fatoum wrote:
> usb_control_msg doesn't (always) return 0 on success.
> Adjust the error checks to explicitly check for negative return values
> instead.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> Should probably be tested before applying. Sascha, can you easily do
> this?
I tested this and can confirm this patch fixes the breakage from the
last patch ;)
Sascha
> ---
> drivers/net/usb/asix.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
> index fc7063095b6c..1140be9d1601 100644
> --- a/drivers/net/usb/asix.c
> +++ b/drivers/net/usb/asix.c
> @@ -255,15 +255,15 @@ static int asix_mdio_read(struct mii_bus *bus, int phy_id, int loc)
> int ret;
>
> ret = asix_set_sw_mii(dev);
> - if (ret)
> + if (ret < 0)
> return ret;
>
> ret = asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, &res);
> - if (ret)
> + if (ret < 0)
> return ret;
>
> ret = asix_set_hw_mii(dev);
> - if (ret)
> + if (ret < 0)
> return ret;
>
> dev_dbg(&dev->edev.dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n",
> @@ -282,14 +282,18 @@ static int asix_mdio_write(struct mii_bus *bus, int phy_id, int loc, u16 val)
> phy_id, loc, val);
>
> ret = asix_set_sw_mii(dev);
> - if (ret)
> + if (ret < 0)
> return ret;
>
> ret = asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res);
> - if (ret)
> + if (ret < 0)
> return ret;
>
> - return asix_set_hw_mii(dev);
> + ret = asix_set_hw_mii(dev);
> + if (ret < 0)
> + return ret;
> +
> + return 0;
> }
>
> static inline int asix_get_phy_addr(struct usbnet *dev)
> --
> 2.28.0
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
` (10 preceding siblings ...)
2020-09-30 7:20 ` [PATCH 12/12] blspec: fix dead assignment Ahmad Fatoum
@ 2020-10-02 4:04 ` Sascha Hauer
11 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2020-10-02 4:04 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Wed, Sep 30, 2020 at 09:19:54AM +0200, Ahmad Fatoum wrote:
> err is evaluated in a ternary condition on return, but if the while
> loop is never entered, it is left uninitialized. Fix this.
>
> Reported-by: clang-analyzer-10
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> drivers/hw_random/mxc-rngc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks
Sascha
>
> diff --git a/drivers/hw_random/mxc-rngc.c b/drivers/hw_random/mxc-rngc.c
> index 3ed25aa61d05..075c20e43745 100644
> --- a/drivers/hw_random/mxc-rngc.c
> +++ b/drivers/hw_random/mxc-rngc.c
> @@ -133,7 +133,7 @@ static int mxc_rngc_data_present(struct hwrng *rng)
> static int mxc_rngc_read(struct hwrng *rng, void *buf, size_t max, bool wait)
> {
> struct mxc_rngc *rngc = container_of(rng, struct mxc_rngc, rng);
> - unsigned int err;
> + unsigned int err = 0;
> int count = 0;
> u32 *data = buf;
>
> --
> 2.28.0
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2020-10-02 4:04 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 7:19 [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 02/12] globalvar: fix uninitialized read of variable when no nvvars exist Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 03/12] commands: uimage: fix indeterminate exit code of command Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 04/12] watchdog: fix division-by-zero when clock rate == 0 Ahmad Fatoum
2020-09-30 7:19 ` [PATCH 05/12] net: usb: asix: propagate errors from MDIO accessors Ahmad Fatoum
2020-09-30 7:24 ` [PATCH] fixup! " Ahmad Fatoum
2020-10-02 4:04 ` Sascha Hauer
2020-09-30 7:19 ` [PATCH 06/12] digest: sha: remove no-op "erase" of automatic variables Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 07/12] common: memsize: eliminate dead store Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 08/12] USB: musb: remove dead stores Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 09/12] fs: squashfs: remove dead stores for xattr_id Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 10/12] reset: remove dead initialization Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 11/12] sandbox: fix behavior with images >= 4G on 32-bit Ahmad Fatoum
2020-09-30 7:20 ` [PATCH 12/12] blspec: fix dead assignment Ahmad Fatoum
2020-10-02 4:04 ` [PATCH 01/12] hw_random: mxc-rngc: fix read of uninitialized variable Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox