From 615828721abfe8c73b5103d4436402ecbf9b9897 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 14 Jul 2023 13:24:50 +0200 Subject: Revert "lib: string: Fix strlcpy return value", fix callers Both the Linux kernel and libbsd agree that strlcpy() should always return strlen(src) and not include the NUL termination. The incorrect U-Boot implementation makes it impossible to check the return value for truncation, and breaks code written with the usual implementation in mind (for example, fdtdec_add_reserved_memory() was subtly broken). I reviewed all callers of strlcpy() and strlcat() and fixed them according to my understanding of the intended function. This reverts commit d3358ecc54be0bc3b4dd11f7a63eab0a2842f772 and adds related fixes. Fixes: d3358ecc54be ("lib: string: Fix strlcpy return value") Signed-off-by: Matthias Schiffer Reviewed-by: Simon Glass Reviewed-by: Sean Anderson --- board/amlogic/vim3/vim3.c | 6 +++--- drivers/fastboot/fb_getvar.c | 2 +- lib/string.c | 14 +++++++------- test/lib/strlcat.c | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/board/amlogic/vim3/vim3.c b/board/amlogic/vim3/vim3.c index fcd60ab..8bdfb30 100644 --- a/board/amlogic/vim3/vim3.c +++ b/board/amlogic/vim3/vim3.c @@ -104,8 +104,8 @@ int meson_ft_board_setup(void *blob, struct bd_info *bd) } /* Update PHY names (mandatory to disable USB3.0) */ - len = strlcpy(data, "usb2-phy0", 32); - len += strlcpy(&data[len], "usb2-phy1", 32 - len); + len = strlcpy(data, "usb2-phy0", 32) + 1; + len += strlcpy(&data[len], "usb2-phy1", 32 - len) + 1; ret = fdt_setprop(blob, node, "phy-names", data, len); if (ret < 0) { printf("vim3: failed to update usb phy names property (%d)\n", ret); @@ -132,7 +132,7 @@ int meson_ft_board_setup(void *blob, struct bd_info *bd) } /* Enable PCIe */ - len = strlcpy(data, "okay", 32); + len = strlcpy(data, "okay", 32) + 1; ret = fdt_setprop(blob, node, "status", data, len); if (ret < 0) { printf("vim3: failed to enable pcie node (%d)\n", ret); diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c index dd3475e..d9f0f07 100644 --- a/drivers/fastboot/fb_getvar.c +++ b/drivers/fastboot/fb_getvar.c @@ -183,7 +183,7 @@ static void __maybe_unused getvar_has_slot(char *part_name, char *response) /* part_name_wslot = part_name + "_a" */ len = strlcpy(part_name_wslot, part_name, PART_NAME_LEN - 3); - if (len > PART_NAME_LEN - 3) + if (len >= PART_NAME_LEN - 3) goto fail; strcat(part_name_wslot, "_a"); diff --git a/lib/string.c b/lib/string.c index ecea755..f2c6147 100644 --- a/lib/string.c +++ b/lib/string.c @@ -116,20 +116,18 @@ char * strncpy(char * dest,const char *src,size_t count) * of course, the buffer size is zero). It does not pad * out the result like strncpy() does. * - * Return: the number of bytes copied + * Return: strlen(src) */ size_t strlcpy(char *dest, const char *src, size_t size) { - if (size) { - size_t srclen = strlen(src); - size_t len = (srclen >= size) ? size - 1 : srclen; + size_t ret = strlen(src); + if (size) { + size_t len = (ret >= size) ? size - 1 : ret; memcpy(dest, src, len); dest[len] = '\0'; - return len + 1; } - - return 0; + return ret; } #endif @@ -191,6 +189,8 @@ char * strncat(char *dest, const char *src, size_t count) * Compatible with *BSD: the result is always a valid NUL-terminated string that * fits in the buffer (unless, of course, the buffer size is zero). It does not * write past @size like strncat() does. + * + * Return: min(strlen(dest), size) + strlen(src) */ size_t strlcat(char *dest, const char *src, size_t size) { diff --git a/test/lib/strlcat.c b/test/lib/strlcat.c index a0ec037..d8453fe 100644 --- a/test/lib/strlcat.c +++ b/test/lib/strlcat.c @@ -43,11 +43,11 @@ static int do_test_strlcat(struct unit_test_state *uts, int line, size_t align1, s2[i] = 32 + 23 * i % (127 - 32); s2[len2 - 1] = '\0'; - expected = len2 < n ? min(len1 + len2 - 1, n) : n; + expected = min(strlen(s2), n) + strlen(s1); actual = strlcat(s2, s1, n); if (expected != actual) { ut_failf(uts, __FILE__, line, __func__, - "strlcat(s2, s1, 2) == len2 < n ? min(len1 + len2, n) : n", + "strlcat(s2, s1, n) == min(len2, n) + len1", "Expected %#zx (%zd), got %#zx (%zd)", expected, expected, actual, actual); return CMD_RET_FAILURE; -- cgit v1.1 From 7c00b80d48cbb28e5f6dfc232c344526e28f7176 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 14 Jul 2023 13:24:51 +0200 Subject: lib/charset: fix u16_strlcat() return value strlcat returns min(strlen(dest), count)+strlen(src). Make u16_strlcat's behaviour the same for consistency. Fixes: eca08ce94ceb ("lib/charset: add u16_strlcat() function") Signed-off-by: Matthias Schiffer --- lib/charset.c | 8 ++++---- test/unicode_ut.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/charset.c b/lib/charset.c index b184275..5e4c4f9 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -444,14 +444,14 @@ u16 *u16_strdup(const void *src) size_t u16_strlcat(u16 *dest, const u16 *src, size_t count) { - size_t destlen = u16_strlen(dest); + size_t destlen = u16_strnlen(dest, count); size_t srclen = u16_strlen(src); - size_t ret = destlen + srclen + 1; + size_t ret = destlen + srclen; if (destlen >= count) return ret; - if (ret > count) - srclen -= ret - count; + if (ret >= count) + srclen -= (ret - count + 1); memcpy(&dest[destlen], src, 2 * srclen); dest[destlen + srclen] = 0x0000; diff --git a/test/unicode_ut.c b/test/unicode_ut.c index b27d711..a9356e2 100644 --- a/test/unicode_ut.c +++ b/test/unicode_ut.c @@ -808,12 +808,12 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts) /* dest and src are empty string */ memset(buf, 0, sizeof(buf)); ret = u16_strlcat(buf, &null_src, sizeof(buf)); - ut_asserteq(1, ret); + ut_asserteq(0, ret); /* dest is empty string */ memset(buf, 0, sizeof(buf)); ret = u16_strlcat(buf, src, sizeof(buf)); - ut_asserteq(5, ret); + ut_asserteq(4, ret); ut_assert(!unicode_test_u16_strcmp(buf, src, 40)); /* src is empty string */ @@ -821,14 +821,14 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts) buf[39] = 0; memcpy(buf, dest, sizeof(dest)); ret = u16_strlcat(buf, &null_src, sizeof(buf)); - ut_asserteq(6, ret); + ut_asserteq(5, ret); ut_assert(!unicode_test_u16_strcmp(buf, dest, 40)); for (i = 0; i <= 40; i++) { memset(buf, 0xCD, (sizeof(buf) - sizeof(u16))); buf[39] = 0; memcpy(buf, dest, sizeof(dest)); - expected = 10; + expected = min(5, i) + 4; ret = u16_strlcat(buf, src, i); ut_asserteq(expected, ret); if (i <= 6) { -- cgit v1.1 From 1ded89e78bca4c43db8e46841c589366202cb2b0 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 25 Jul 2023 09:50:08 +0300 Subject: cmd: Fix an error code in cmd_mux_find() This returns the wrong variable. It ends up returning NULL when it was suppose to return an error pointer. Signed-off-by: Dan Carpenter --- cmd/mux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/mux.c b/cmd/mux.c index 833266f..c75907a 100644 --- a/cmd/mux.c +++ b/cmd/mux.c @@ -49,7 +49,7 @@ static struct mux_control *cmd_mux_find(char *const argv[]) chip = dev_get_uclass_priv(dev); if (!chip) - return ERR_PTR(ret); + return ERR_PTR(-EINVAL); if (id >= chip->controllers) return ERR_PTR(-EINVAL); -- cgit v1.1 From 57175285774751ca751d3d5e9f045d6af95ea43b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 25 Jul 2023 09:50:26 +0300 Subject: cmd: Fix a size parameter in test_readonly() The parentheses are in the wrong place so this passes the number of bytes to write as "sizeof(index_0) != TPM_SUCCESS" when just "sizeof(index_0)" was intended. (1 byte vs 4 bytes). Signed-off-by: Dan Carpenter --- cmd/tpm_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/tpm_test.c b/cmd/tpm_test.c index c4ed8e5..9bdc9c6 100644 --- a/cmd/tpm_test.c +++ b/cmd/tpm_test.c @@ -294,8 +294,8 @@ static int test_readonly(struct udevice *dev) */ index_0 += 1; if (tpm_nv_write_value(dev, INDEX0, (uint8_t *)&index_0, - sizeof(index_0) != - TPM_SUCCESS)) { + sizeof(index_0)) != + TPM_SUCCESS) { pr_err("\tcould not write index 0\n"); } tpm_nv_write_value_lock(dev, INDEX0); -- cgit v1.1 From cc05d352fbc2b5df7f3aa4bd8a0711df5a1efa68 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 26 Jul 2023 09:54:08 +0300 Subject: video: Add parentheses around VNBYTES() macro The VNBYTES() macro needs to have parentheses to prevent some (harmless) macro expansion bugs. The VNBYTES() macro is used like this: VID_TO_PIXEL(x) * VNBYTES(vid_priv->bpix) The * operation is done before the / operation. It still ends up with the same results, but it's not ideal. Signed-off-by: Dan Carpenter Reviewed-by: Simon Glass --- include/video.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/video.h b/include/video.h index 2699151..66d109c 100644 --- a/include/video.h +++ b/include/video.h @@ -58,7 +58,7 @@ enum video_log2_bpp { * Convert enum video_log2_bpp to bytes and bits. Note we omit the outer * brackets to allow multiplication by fractional pixels. */ -#define VNBYTES(bpix) (1 << (bpix)) / 8 +#define VNBYTES(bpix) ((1 << (bpix)) / 8) #define VNBITS(bpix) (1 << (bpix)) -- cgit v1.1 From d8ac619a172451f46efd421d280b639c224b3de6 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 26 Jul 2023 09:58:34 +0300 Subject: cros_ec: Fix an error code is cros_ec_get_sku_id() The ec_command_inptr() function returns negative error codes or the number of bytes that it was able to read. The cros_ec_get_sku_id() function should return negative error codes. Right now it returns positive error codes or negative byte counts. Signed-off-by: Dan Carpenter Reviewed-by: Simon Glass --- drivers/misc/cros_ec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 621d175..9c1e6a5 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -1100,8 +1100,11 @@ int cros_ec_get_sku_id(struct udevice *dev) ret = ec_command_inptr(dev, EC_CMD_GET_SKU_ID, 0, NULL, 0, (uint8_t **)&r, sizeof(*r)); - if (ret != sizeof(*r)) - return -ret; + if (ret != sizeof(*r)) { + if (ret >= 0) + ret = -EIO; + return ret; + } return r->sku_id; } -- cgit v1.1 From c331efd08766aa610aa14c957856ef5b0fa915df Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 26 Jul 2023 09:59:04 +0300 Subject: fs: btrfs: Prevent error pointer dereference in list_subvolums() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If btrfs_read_fs_root() fails with -ENOENT, then we go to the next entry. Fine. But if it fails for a different reason then we need to clean up and return an error code. In the current code it doesn't clean up but instead dereferences "root" and crashes. Signed-off-by: Dan Carpenter Reviewed-by: Marek BehĂșn Reviewed-by: Qu Wenruo --- fs/btrfs/subvolume.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/subvolume.c b/fs/btrfs/subvolume.c index d446e7a..68ca7e4 100644 --- a/fs/btrfs/subvolume.c +++ b/fs/btrfs/subvolume.c @@ -199,6 +199,7 @@ static int list_subvolums(struct btrfs_fs_info *fs_info) ret = PTR_ERR(root); if (ret == -ENOENT) goto next; + goto out; } ret = list_one_subvol(root, result); if (ret < 0) -- cgit v1.1 From d7a92e9cb22497562b1632aebc0d625b17bbfd51 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 26 Jul 2023 09:59:52 +0300 Subject: fdt: off by one in ofnode_lookup_fdt() The "oftree_count" is the number of entries which have been set in the oftree_list[] array. If all the entries have been initialized then this off by one would result in reading one element beyond the end of the array. Signed-off-by: Dan Carpenter Reviewed-by: Simon Glass --- drivers/core/ofnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 8df16e5..a4dc9bd 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -103,7 +103,7 @@ void *ofnode_lookup_fdt(ofnode node) if (gd->flags & GD_FLG_RELOC) { uint i = OFTREE_TREE_ID(node.of_offset); - if (i > oftree_count) { + if (i >= oftree_count) { log_debug("Invalid tree ID %x\n", i); return NULL; } -- cgit v1.1 From f9a12cc92a569698cae0630d795bac14f4a875fc Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 26 Jul 2023 10:00:33 +0300 Subject: remoteproc: uclass: Clean up a return We know that "pa" is non-NULL so it's nicer to just return zero instead of return !pa. This has no effect on runtime behavior. Signed-off-by: Dan Carpenter Reviewed-by: Simon Glass --- drivers/remoteproc/rproc-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/remoteproc/rproc-uclass.c b/drivers/remoteproc/rproc-uclass.c index 50bcc90..19fe405 100644 --- a/drivers/remoteproc/rproc-uclass.c +++ b/drivers/remoteproc/rproc-uclass.c @@ -689,7 +689,7 @@ static int alloc_vring(struct udevice *dev, struct fw_rsc_vdev *rsc, int i) debug("alloc_mem(%#x, %d): %p\n", size, order, pa); vring->da = (uintptr_t)pa; - return !pa; + return 0; } static int handle_vdev(struct udevice *dev, struct fw_rsc_vdev *rsc, -- cgit v1.1 From bb34bc0c96168857d6b5127d3487223b0ea8cfa5 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 27 Jul 2023 10:12:39 +0300 Subject: cmd: pxe_utils: add some missing tabs These lines are supposed to be indented one more tab. Otherwise it's confusing to read. Signed-off-by: Dan Carpenter Reviewed-by: Patrick Delaunay --- boot/pxe_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index d13c47d..ac1414a 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -702,8 +702,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) } } - if (label->kaslrseed) - label_boot_kaslrseed(); + if (label->kaslrseed) + label_boot_kaslrseed(); #ifdef CONFIG_OF_LIBFDT_OVERLAY if (label->fdtoverlays) -- cgit v1.1 From be5f9a77f8bc83a3f93d26a50acc047d2bbee908 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 27 Jul 2023 10:12:58 +0300 Subject: test: unicode: fix a sizeof() vs ARRAY_SIZE() bug The u16_strlcat() is in units of u16 not bytes. So the limit needs to be ARRAY_SIZE() instead of sizeof(). Signed-off-by: Dan Carpenter --- test/unicode_ut.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unicode_ut.c b/test/unicode_ut.c index a9356e2..1d0d90c 100644 --- a/test/unicode_ut.c +++ b/test/unicode_ut.c @@ -807,12 +807,12 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts) /* dest and src are empty string */ memset(buf, 0, sizeof(buf)); - ret = u16_strlcat(buf, &null_src, sizeof(buf)); + ret = u16_strlcat(buf, &null_src, ARRAY_SIZE(buf)); ut_asserteq(0, ret); /* dest is empty string */ memset(buf, 0, sizeof(buf)); - ret = u16_strlcat(buf, src, sizeof(buf)); + ret = u16_strlcat(buf, src, ARRAY_SIZE(buf)); ut_asserteq(4, ret); ut_assert(!unicode_test_u16_strcmp(buf, src, 40)); @@ -820,7 +820,7 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts) memset(buf, 0xCD, (sizeof(buf) - sizeof(u16))); buf[39] = 0; memcpy(buf, dest, sizeof(dest)); - ret = u16_strlcat(buf, &null_src, sizeof(buf)); + ret = u16_strlcat(buf, &null_src, ARRAY_SIZE(buf)); ut_asserteq(5, ret); ut_assert(!unicode_test_u16_strcmp(buf, dest, 40)); -- cgit v1.1 From 1678e269c565fc47daf09e79e5a4fdfe59e20870 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 27 Jul 2023 10:16:03 +0300 Subject: cramfs: clean up some error messages This line break is not done correctly. We don't want to have all those tabs in the printed output. Signed-off-by: Dan Carpenter Reviewed-by: Simon Glass --- fs/cramfs/cramfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c index 6c017ce..abb2de3 100644 --- a/fs/cramfs/cramfs.c +++ b/fs/cramfs/cramfs.c @@ -166,8 +166,7 @@ static unsigned long cramfs_resolve (unsigned long begin, unsigned long offset, unsigned long ret; char *link; if (p && strlen(p)) { - printf ("unsupported symlink to \ - non-terminal path\n"); + printf ("unsupported symlink to non-terminal path\n"); return 0; } link = cramfs_uncompress_link (begin, @@ -177,8 +176,7 @@ static unsigned long cramfs_resolve (unsigned long begin, unsigned long offset, namelen, namelen, name); return 0; } else if (link[0] == '/') { - printf ("unsupported symlink to \ - absolute path\n"); + printf ("unsupported symlink to absolute path\n"); free (link); return 0; } -- cgit v1.1 From 0c0d471e2be018342fd191892e1cccc2231db90b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 31 Jul 2023 17:03:59 +0300 Subject: cmd: improve string matching for hex Match the "=0x" instead of just "=0". Signed-off-by: Dan Carpenter Reviewed-by: Heinrich.Schuchardt Reviewed-by: Simon Glass Reviewed-by: Ilias Apalodimas --- cmd/nvedit_efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 24944ab..7a30b5c 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -262,7 +262,7 @@ static int append_value(char **bufp, size_t *sizep, char *data) char *tmp_buf = NULL, *new_buf = NULL, *value; unsigned long len = 0; - if (!strncmp(data, "=0x", 2)) { /* hexadecimal number */ + if (!strncmp(data, "=0x", 3)) { /* hexadecimal number */ union { u8 u8; u16 u16; -- cgit v1.1 From d864bd0e21ad6ab901bc6365abc8c3dbebe3ad29 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 31 Jul 2023 17:08:29 +0300 Subject: expo: allocate correct amount of memory This should be allocating the memory for "item" instead of "menu". The item struct is 48 bytes instead of 96 (assuming a 64bit system) so this saves a little memory. Signed-off-by: Dan Carpenter Reviewed-by: Simon Glass --- boot/scene_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/scene_menu.c b/boot/scene_menu.c index 8a355f8..57ffb52 100644 --- a/boot/scene_menu.c +++ b/boot/scene_menu.c @@ -416,7 +416,7 @@ int scene_menuitem(struct scene *scn, uint menu_id, const char *name, uint id, if (!scene_obj_find(scn, label_id, SCENEOBJT_TEXT)) return log_msg_ret("txt", -EINVAL); - item = calloc(1, sizeof(struct scene_obj_menu)); + item = calloc(1, sizeof(struct scene_menitem)); if (!item) return log_msg_ret("item", -ENOMEM); item->name = strdup(name); -- cgit v1.1 From 939390b203dde8a0176dbfa272dcb7bc54949baf Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 31 Jul 2023 17:08:41 +0300 Subject: test: fix a couple NULL vs IS_ERR() checks The x509_cert_parse() and pkcs7_parse_message() functions return error pointers. They don't return NULL. Update the checks accordingly. Signed-off-by: Dan Carpenter Reviewed-by: Simon Glass --- test/lib/asn1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib/asn1.c b/test/lib/asn1.c index 8661fdd..a66cdd7 100644 --- a/test/lib/asn1.c +++ b/test/lib/asn1.c @@ -120,7 +120,7 @@ static int lib_asn1_x509(struct unit_test_state *uts) cert = x509_cert_parse(cert_data, cert_data_len); - ut_assertf(cert != NULL, "decoding failed\n"); + ut_assertf(!IS_ERR(cert), "decoding failed\n"); ut_assertf(!strcmp(cert->subject, "Linaro: Tester"), "subject doesn't match\n"); ut_assertf(!strcmp(cert->issuer, "Linaro: Tester"), @@ -313,7 +313,7 @@ static int lib_asn1_pkcs7(struct unit_test_state *uts) pkcs7 = pkcs7_parse_message(image_pk7, image_pk7_len); - ut_assertf(pkcs7 != NULL, "decoding failed\n"); + ut_assertf(!IS_ERR(pkcs7), "decoding failed\n"); ut_assertf(pkcs7->data_len == 104, "signature size doesn't match\n"); ut_assertf(pkcs7->signed_infos != NULL, "sign-info doesn't exist\n"); ut_assertf(pkcs7->signed_infos->msgdigest_len == 32, -- cgit v1.1 From 08404fa2087946bb370430d466fe5011f18ef072 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 3 Aug 2023 13:29:34 +0300 Subject: btrfs: fix some error checking for btrfs_decompress() The btrfs_decompress() function mostly (u32)-1 on error but it can also return -EPERM or other kernel error codes from zstd_decompress(). The "ret" variable is an int, so we could just check for negatives. Signed-off-by: Dan Carpenter Reviewed-by: Qu Wenruo --- fs/btrfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 38e285b..4691612 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -390,7 +390,7 @@ int btrfs_read_extent_inline(struct btrfs_path *path, csize); ret = btrfs_decompress(btrfs_file_extent_compression(leaf, fi), cbuf, csize, dbuf, dsize); - if (ret == (u32)-1) { + if (ret < 0) { ret = -EIO; goto out; } @@ -500,7 +500,7 @@ int btrfs_read_extent_reg(struct btrfs_path *path, ret = btrfs_decompress(btrfs_file_extent_compression(leaf, fi), cbuf, csize, dbuf, dsize); - if (ret == (u32)-1) { + if (ret < 0) { ret = -EIO; goto out; } -- cgit v1.1 From 1a549c8961a6db72db374a4db2be598b30c9c46d Mon Sep 17 00:00:00 2001 From: Ilya Lukin <4.shket@gmail.com> Date: Fri, 14 Jul 2023 17:39:32 +0300 Subject: crc32: Drop duplicates crc header includes Fixes: 3db711085752 ("crc32: Use the crc.h header for crc functions") Signed-off-by: Ilya Lukin <4.shket@gmail.com> --- board/sunxi/board.c | 1 - boot/android_ab.c | 1 - common/hash.c | 1 - lib/crc32.c | 1 - tools/default_image.c | 1 - 5 files changed, 5 deletions(-) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index f321cd5..de0f350 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -33,7 +33,6 @@ #include #include #include -#include #ifndef CONFIG_ARM64 #include #endif diff --git a/boot/android_ab.c b/boot/android_ab.c index 73b55c1..0f20a34 100644 --- a/boot/android_ab.c +++ b/boot/android_ab.c @@ -12,7 +12,6 @@ #include #include #include -#include /** * Compute the CRC-32 of the bootloader control struct. diff --git a/common/hash.c b/common/hash.c index cbffdfd..159179e 100644 --- a/common/hash.c +++ b/common/hash.c @@ -21,7 +21,6 @@ #include #include #include -#include #else #include "mkimage.h" #include diff --git a/lib/crc32.c b/lib/crc32.c index aa94d70..f6fad8c 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -10,7 +10,6 @@ #ifdef USE_HOSTCC #include -#include #else #include #include diff --git a/tools/default_image.c b/tools/default_image.c index 0e49ab3..04bc85b 100644 --- a/tools/default_image.c +++ b/tools/default_image.c @@ -15,7 +15,6 @@ #include "imagetool.h" #include "mkimage.h" -#include #include #include -- cgit v1.1 From d8cb1dc91413baf8ac3388aab2070a8f35b13c0b Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sat, 22 Jul 2023 00:15:21 +0800 Subject: board_f: Cosmetic style fix Some coding convention fixes for print_resetinfo(). Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- common/board_f.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/board_f.c b/common/board_f.c index 7d2c380..50edac5 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -148,11 +148,12 @@ static int print_resetinfo(void) bool status_printed = false; int ret; - /* Not all boards have sysreset drivers available during early + /* + * Not all boards have sysreset drivers available during early * boot, so don't fail if one can't be found. */ for (ret = uclass_first_device_check(UCLASS_SYSRESET, &dev); dev; - ret = uclass_next_device_check(&dev)) { + ret = uclass_next_device_check(&dev)) { if (ret) { debug("%s: %s sysreset device (error: %d)\n", __func__, dev->name, ret); -- cgit v1.1 From 70fdcc704a978acb4de5e891469825596c0d292e Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 27 Jul 2023 18:50:14 +0200 Subject: pci: correct function name in message If an error message contains a function name, it should match the name of the function throwing the message. Fixes: 7739d93d8288 ("pci: Match region flags using a mask") Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- drivers/pci/pci-uclass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 632c1a6..7f3d6dd 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -1446,7 +1446,7 @@ phys_addr_t dm_pci_bus_to_phys(struct udevice *dev, pci_addr_t bus_addr, return res->phys_start + offset; } - puts("pci_hose_bus_to_phys: invalid physical address\n"); + puts("dm_pci_bus_to_phys: invalid physical address\n"); return 0; } @@ -1486,7 +1486,7 @@ pci_addr_t dm_pci_phys_to_bus(struct udevice *dev, phys_addr_t phys_addr, return res->bus_start + offset; } - puts("pci_hose_phys_to_bus: invalid physical address\n"); + puts("dm_pci_phys_to_bus: invalid physical address\n"); return 0; } -- cgit v1.1