All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]makedumpfile.h:makedumpfile.h: check the return value
@ 2015-08-24  3:15 Chao Fan
  2015-08-24  3:15 ` [PATCH]makedumpfile.c: check rhe return value ofset_page_size Chao Fan
  2015-08-24  3:15 ` [PATCH] sadump_info.c: unsigned_compare: This less-than-zero comparison of an unsigned value is never true Chao Fan
  0 siblings, 2 replies; 4+ messages in thread
From: Chao Fan @ 2015-08-24  3:15 UTC (permalink / raw)
  To: kexec; +Cc: Chao Fan

makedumpfile.h:1748: check_return: Calling function "lseek" without
checking return value.

makedumpfile.c:3394: example_checked: "lseek(bitmap->fd, offset,
SEEK_SET);" has its value checked, But in makedumpfile.h:1748, the
function will not check the return value.

Signed-off-by: Chao Fan <cfan@redhat.com>
---
 makedumpfile.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/makedumpfile.h b/makedumpfile.h
index d2fadbd..b8b44e0 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1745,7 +1745,12 @@ is_dumpable(struct dump_bitmap *bitmap, mdf_pfn_t pfn)
 	off_t offset;
 	if (pfn == 0 || bitmap->no_block != pfn/PFN_BUFBITMAP) {
 		offset = bitmap->offset + BUFSIZE_BITMAP*(pfn/PFN_BUFBITMAP);
-		lseek(bitmap->fd, offset, SEEK_SET);
+		if (lseek(bitmap->fd, old_offset, SEEK_SET) < 0 ) {
+			ERRMSG("Can't seek the bitmap(%s). %s\n",
+				bitmap->file_name, strerror(errno));
+			return FALSE;
+		}
+
 		read(bitmap->fd, bitmap->buf, BUFSIZE_BITMAP);
 		if (pfn == 0)
 			bitmap->no_block = 0;
-- 
2.4.3


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [PATCH]makedumpfile.c: check rhe return value ofset_page_size
  2015-08-24  3:15 [PATCH]makedumpfile.h:makedumpfile.h: check the return value Chao Fan
@ 2015-08-24  3:15 ` Chao Fan
  2015-08-24  3:26   ` Chao Fan
  2015-08-24  3:15 ` [PATCH] sadump_info.c: unsigned_compare: This less-than-zero comparison of an unsigned value is never true Chao Fan
  1 sibling, 1 reply; 4+ messages in thread
From: Chao Fan @ 2015-08-24  3:15 UTC (permalink / raw)
  To: kexec; +Cc: Chao Fan

check_return: Calling function "set_page_size" without checking
return value (as is done elsewhere 5 out of 6 times).

makedumpfile.c:8793: example_checked: "set_page_size(dh.block_size)"
has its value checked in "set_page_size(dh.block_size)". But in
makedumpfile.c:3213, the function "set_page_size" will not check
the return value.

Signed-off-by: Chao Fan <cfan@redhat.com>
---
 makedumpfile.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 32f5459..53efc04 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -3213,7 +3213,8 @@ initial(void)
 			MSG("because the cyclic mode doesn't support sadump format.\n");
 		}
 
-		set_page_size(sadump_page_size());
+		if (!set_page_size(sadump_page_size()))
+			return FALSE;
 
 		if (!sadump_initialize_bitmap_memory())
 			return FALSE;
-- 
2.4.3


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [PATCH] sadump_info.c: unsigned_compare: This less-than-zero comparison of an unsigned value is never true.
  2015-08-24  3:15 [PATCH]makedumpfile.h:makedumpfile.h: check the return value Chao Fan
  2015-08-24  3:15 ` [PATCH]makedumpfile.c: check rhe return value ofset_page_size Chao Fan
@ 2015-08-24  3:15 ` Chao Fan
  1 sibling, 0 replies; 4+ messages in thread
From: Chao Fan @ 2015-08-24  3:15 UTC (permalink / raw)
  To: kexec; +Cc: Chao Fan

In sadump_info.c:432: unsigned long block_size =
SADUMP_DEFAULT_BLOCK_SIZE.
So block_size is unsigned long value and it is bigger than zero.
And this comparison is useful.

Signed-off-by: Chao Fan <cfan@redhat.com>
---
 sadump_info.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/sadump_info.c b/sadump_info.c
index e2c4f03..e8154f4 100644
--- a/sadump_info.c
+++ b/sadump_info.c
@@ -465,9 +465,6 @@ read_sadump_header(char *filename)
 	smh = si->smh_memory;
 
 restart:
-	if (block_size < 0)
-		return FALSE;
-
 	if (!read_device(sph, block_size, &offset))
 		return ERROR;
 
-- 
2.4.3


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH]makedumpfile.c: check rhe return value ofset_page_size
  2015-08-24  3:15 ` [PATCH]makedumpfile.c: check rhe return value ofset_page_size Chao Fan
@ 2015-08-24  3:26   ` Chao Fan
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Fan @ 2015-08-24  3:26 UTC (permalink / raw)
  To: kexec

Sorry, the format is not good. I will rearrange the patches and repost.

So NACK these patches.

Maybe they should be put in one patch since they are used to remove the coverity scan error report.

----- Original Message -----
> From: "Chao Fan" <cfan@redhat.com>
> To: kexec@lists.infradead.org
> Cc: "Chao Fan" <cfan@redhat.com>
> Sent: Monday, August 24, 2015 11:15:52 AM
> Subject: [PATCH]makedumpfile.c: check rhe return value ofset_page_size
> 
> check_return: Calling function "set_page_size" without checking
> return value (as is done elsewhere 5 out of 6 times).
> 
> makedumpfile.c:8793: example_checked: "set_page_size(dh.block_size)"
> has its value checked in "set_page_size(dh.block_size)". But in
> makedumpfile.c:3213, the function "set_page_size" will not check
> the return value.
> 
> Signed-off-by: Chao Fan <cfan@redhat.com>
> ---
>  makedumpfile.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/makedumpfile.c b/makedumpfile.c
> index 32f5459..53efc04 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -3213,7 +3213,8 @@ initial(void)
>  			MSG("because the cyclic mode doesn't support sadump format.\n");
>  		}
>  
> -		set_page_size(sadump_page_size());
> +		if (!set_page_size(sadump_page_size()))
> +			return FALSE;
>  
>  		if (!sadump_initialize_bitmap_memory())
>  			return FALSE;
> --
> 2.4.3
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

end of thread, other threads:[~2015-08-24  3:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-24  3:15 [PATCH]makedumpfile.h:makedumpfile.h: check the return value Chao Fan
2015-08-24  3:15 ` [PATCH]makedumpfile.c: check rhe return value ofset_page_size Chao Fan
2015-08-24  3:26   ` Chao Fan
2015-08-24  3:15 ` [PATCH] sadump_info.c: unsigned_compare: This less-than-zero comparison of an unsigned value is never true Chao Fan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.