linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] libf2fs: Fix using uninitialized variables error in get_device_info()
@ 2023-11-08 12:38 zangyangyang1 via Linux-f2fs-devel
  2023-11-09  8:37 ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: zangyangyang1 via Linux-f2fs-devel @ 2023-11-08 12:38 UTC (permalink / raw)
  To: chao; +Cc: jaegeuk, zangyangyang1, linux-f2fs-devel

[-- Attachment #1: Type: text/plain, Size: 1454 bytes --]

This issue comes from a static code scanning tool.
When c.sparse_mode is 1, stat_buf will not be initialized,
but it will be used next.
If this issue does not require modification, please ignore this commit.

Signed-off-by: zangyangyang1 <zangyangyang1@xiaomi.com>
---
 lib/libf2fs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 995e42d..0398c52 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -933,6 +933,7 @@ int get_device_info(int i)

        stat_buf = malloc(sizeof(struct stat));
        ASSERT(stat_buf);
+       memset(stat_buf, 0, sizeof(struct stat));

        if (!c.sparse_mode) {
                if (stat(dev->path, stat_buf) < 0 ) {
--
2.40.1

#/******±¾Óʼþ¼°Æä¸½¼þº¬ÓÐСÃ×¹«Ë¾µÄ±£ÃÜÐÅÏ¢£¬½öÏÞÓÚ·¢Ë͸øÉÏÃæµØÖ·ÖÐÁгöµÄ¸öÈË»òȺ×é¡£½ûÖ¹ÈÎºÎÆäËûÈËÒÔÈκÎÐÎʽʹÓ㨰üÀ¨µ«²»ÏÞÓÚÈ«²¿»ò²¿·ÖµØÐ¹Â¶¡¢¸´ÖÆ¡¢»òÉ¢·¢£©±¾ÓʼþÖеÄÐÅÏ¢¡£Èç¹ûÄú´íÊÕÁ˱¾Óʼþ£¬ÇëÄúÁ¢¼´µç»°»òÓʼþ֪ͨ·¢¼þÈ˲¢É¾³ý±¾Óʼþ£¡ This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#


[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 179 bytes --]

_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH] libf2fs: Fix using uninitialized variables error in get_device_info()
  2023-11-08 12:38 [f2fs-dev] [PATCH] libf2fs: Fix using uninitialized variables error in get_device_info() zangyangyang1 via Linux-f2fs-devel
@ 2023-11-09  8:37 ` Chao Yu
  2023-11-09 15:47   ` [f2fs-dev] [PATCH V2] " zangyangyang1 via Linux-f2fs-devel
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2023-11-09  8:37 UTC (permalink / raw)
  To: zangyangyang1; +Cc: jaegeuk, linux-f2fs-devel

On 2023/11/8 20:38, zangyangyang1 wrote:
> This issue comes from a static code scanning tool.
> When c.sparse_mode is 1, stat_buf will not be initialized,
> but it will be used next.
> If this issue does not require modification, please ignore this commit.
> 
> Signed-off-by: zangyangyang1 <zangyangyang1@xiaomi.com>
> ---
>   lib/libf2fs.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index 995e42d..0398c52 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -933,6 +933,7 @@ int get_device_info(int i)
> 
>          stat_buf = malloc(sizeof(struct stat));

Use calloc() instead of malloc()?

Thanks,

>          ASSERT(stat_buf);
> +       memset(stat_buf, 0, sizeof(struct stat));
> 
>          if (!c.sparse_mode) {
>                  if (stat(dev->path, stat_buf) < 0 ) {
> --
> 2.40.1


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [f2fs-dev] [PATCH V2] libf2fs: Fix using uninitialized variables error in get_device_info()
  2023-11-09  8:37 ` Chao Yu
@ 2023-11-09 15:47   ` zangyangyang1 via Linux-f2fs-devel
  2023-11-10  4:03     ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: zangyangyang1 via Linux-f2fs-devel @ 2023-11-09 15:47 UTC (permalink / raw)
  To: chao; +Cc: jaegeuk, zangyangyang1, linux-f2fs-devel

[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]

This issue comes from a static code scanning tool.
When c.sparse_mode is 1, stat_buf will not be initialized,
but it will be used next.
If this issue does not require modification, please ignore this commit.

Signed-off-by: zangyangyang1 <zangyangyang1@xiaomi.com>
---
Changes since v1:
- Use calloc() instead of malloc()
---
 lib/libf2fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 995e42d..47d4e49 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -931,7 +931,7 @@ int get_device_info(int i)
                }
        }

-       stat_buf = malloc(sizeof(struct stat));
+       stat_buf = calloc(1, sizeof(struct stat));
        ASSERT(stat_buf);

        if (!c.sparse_mode) {
--
2.40.1

#/******±¾Óʼþ¼°Æä¸½¼þº¬ÓÐСÃ×¹«Ë¾µÄ±£ÃÜÐÅÏ¢£¬½öÏÞÓÚ·¢Ë͸øÉÏÃæµØÖ·ÖÐÁгöµÄ¸öÈË»òȺ×é¡£½ûÖ¹ÈÎºÎÆäËûÈËÒÔÈκÎÐÎʽʹÓ㨰üÀ¨µ«²»ÏÞÓÚÈ«²¿»ò²¿·ÖµØÐ¹Â¶¡¢¸´ÖÆ¡¢»òÉ¢·¢£©±¾ÓʼþÖеÄÐÅÏ¢¡£Èç¹ûÄú´íÊÕÁ˱¾Óʼþ£¬ÇëÄúÁ¢¼´µç»°»òÓʼþ֪ͨ·¢¼þÈ˲¢É¾³ý±¾Óʼþ£¡ This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#


[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 179 bytes --]

_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH V2] libf2fs: Fix using uninitialized variables error in get_device_info()
  2023-11-09 15:47   ` [f2fs-dev] [PATCH V2] " zangyangyang1 via Linux-f2fs-devel
@ 2023-11-10  4:03     ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2023-11-10  4:03 UTC (permalink / raw)
  To: zangyangyang1; +Cc: jaegeuk, linux-f2fs-devel

On 2023/11/9 23:47, zangyangyang1 wrote:
> This issue comes from a static code scanning tool.
> When c.sparse_mode is 1, stat_buf will not be initialized,
> but it will be used next.
> If this issue does not require modification, please ignore this commit.
> 
> Signed-off-by: zangyangyang1 <zangyangyang1@xiaomi.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-10  4:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-08 12:38 [f2fs-dev] [PATCH] libf2fs: Fix using uninitialized variables error in get_device_info() zangyangyang1 via Linux-f2fs-devel
2023-11-09  8:37 ` Chao Yu
2023-11-09 15:47   ` [f2fs-dev] [PATCH V2] " zangyangyang1 via Linux-f2fs-devel
2023-11-10  4:03     ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).