* [patch] eCryptfs: remove unneeded checks in virt_to_scatterlist()
@ 2013-01-26 7:48 Dan Carpenter
2013-01-29 1:23 ` Tyler Hicks
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2013-01-26 7:48 UTC (permalink / raw)
To: Tyler Hicks; +Cc: Dustin Kirkland, ecryptfs, kernel-janitors
This is always called with a valid "sg" pointer. My static checker
complains because the call to sg_init_table() dereferences "sg" before
we reach the checks.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index a7b0c2d..d5c25db 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -301,17 +301,14 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
while (size > 0 && i < sg_size) {
pg = virt_to_page(addr);
offset = offset_in_page(addr);
- if (sg)
- sg_set_page(&sg[i], pg, 0, offset);
+ sg_set_page(&sg[i], pg, 0, offset);
remainder_of_page = PAGE_CACHE_SIZE - offset;
if (size >= remainder_of_page) {
- if (sg)
- sg[i].length = remainder_of_page;
+ sg[i].length = remainder_of_page;
addr += remainder_of_page;
size -= remainder_of_page;
} else {
- if (sg)
- sg[i].length = size;
+ sg[i].length = size;
addr += size;
size = 0;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch] eCryptfs: remove unneeded checks in virt_to_scatterlist()
2013-01-26 7:48 [patch] eCryptfs: remove unneeded checks in virt_to_scatterlist() Dan Carpenter
@ 2013-01-29 1:23 ` Tyler Hicks
0 siblings, 0 replies; 2+ messages in thread
From: Tyler Hicks @ 2013-01-29 1:23 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Dustin Kirkland, ecryptfs, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1223 bytes --]
On 2013-01-26 10:48:42, Dan Carpenter wrote:
> This is always called with a valid "sg" pointer. My static checker
> complains because the call to sg_init_table() dereferences "sg" before
> we reach the checks.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Thanks, Dan! I've tested and pushed this patch to the eCryptfs next
branch.
Tyler
>
> diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
> index a7b0c2d..d5c25db 100644
> --- a/fs/ecryptfs/crypto.c
> +++ b/fs/ecryptfs/crypto.c
> @@ -301,17 +301,14 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
> while (size > 0 && i < sg_size) {
> pg = virt_to_page(addr);
> offset = offset_in_page(addr);
> - if (sg)
> - sg_set_page(&sg[i], pg, 0, offset);
> + sg_set_page(&sg[i], pg, 0, offset);
> remainder_of_page = PAGE_CACHE_SIZE - offset;
> if (size >= remainder_of_page) {
> - if (sg)
> - sg[i].length = remainder_of_page;
> + sg[i].length = remainder_of_page;
> addr += remainder_of_page;
> size -= remainder_of_page;
> } else {
> - if (sg)
> - sg[i].length = size;
> + sg[i].length = size;
> addr += size;
> size = 0;
> }
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-29 1:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-26 7:48 [patch] eCryptfs: remove unneeded checks in virt_to_scatterlist() Dan Carpenter
2013-01-29 1:23 ` Tyler Hicks
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).