Re: [PATCH] btrfs-progs: Fix NULL pointer when receive clone operation
At 12/15/2016 04:07 PM, Tsutomu Itoh wrote: On 2016/12/15 16:28, Qu Wenruo wrote: The subvol_info returned from subvol_uuid_search() can be NULL. So the branch checking IS_ERR(si) should also check if it's NULL. Reported-by: Tsutomu ItohSigned-off-by: Qu Wenruo --- cmds-receive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds-receive.c b/cmds-receive.c index cb42aa2..c8f2fff 100644 --- a/cmds-receive.c +++ b/cmds-receive.c @@ -750,7 +750,7 @@ static int process_clone(const char *path, u64 offset, u64 len, si = subvol_uuid_search(>sus, 0, clone_uuid, clone_ctransid, NULL, subvol_search_by_received_uuid); - if (IS_ERR(si)) { + if (IS_ERR(si) || !si) { Tested-by: Tsutomu Itoh But I like if (!si || IS_ERR(si)) { Thanks, Tsutomu Thanks for the test. But it seems that there are more such problems. I'd better introduce a new macro, IS_ERR_OR_NULL() to handle it. Since all the modification commit a2f7af94 introduced can return NULL. I'll update the patchset soon. Thanks, Qu if (memcmp(clone_uuid, rctx->cur_subvol.received_uuid, BTRFS_UUID_SIZE) == 0) { /* TODO check generation of extent */ -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] btrfs-progs: Fix NULL pointer when receive clone operation
On 2016/12/15 16:28, Qu Wenruo wrote: > The subvol_info returned from subvol_uuid_search() can be NULL. > So the branch checking IS_ERR(si) should also check if it's NULL. > > Reported-by: Tsutomu Itoh> Signed-off-by: Qu Wenruo > --- > cmds-receive.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/cmds-receive.c b/cmds-receive.c > index cb42aa2..c8f2fff 100644 > --- a/cmds-receive.c > +++ b/cmds-receive.c > @@ -750,7 +750,7 @@ static int process_clone(const char *path, u64 offset, > u64 len, > si = subvol_uuid_search(>sus, 0, clone_uuid, clone_ctransid, > NULL, > subvol_search_by_received_uuid); > - if (IS_ERR(si)) { > + if (IS_ERR(si) || !si) { Tested-by: Tsutomu Itoh But I like if (!si || IS_ERR(si)) { Thanks, Tsutomu > if (memcmp(clone_uuid, rctx->cur_subvol.received_uuid, > BTRFS_UUID_SIZE) == 0) { > /* TODO check generation of extent */ > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] btrfs-progs: Fix NULL pointer when receive clone operation
The subvol_info returned from subvol_uuid_search() can be NULL. So the branch checking IS_ERR(si) should also check if it's NULL. Reported-by: Tsutomu ItohSigned-off-by: Qu Wenruo --- cmds-receive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds-receive.c b/cmds-receive.c index cb42aa2..c8f2fff 100644 --- a/cmds-receive.c +++ b/cmds-receive.c @@ -750,7 +750,7 @@ static int process_clone(const char *path, u64 offset, u64 len, si = subvol_uuid_search(>sus, 0, clone_uuid, clone_ctransid, NULL, subvol_search_by_received_uuid); - if (IS_ERR(si)) { + if (IS_ERR(si) || !si) { if (memcmp(clone_uuid, rctx->cur_subvol.received_uuid, BTRFS_UUID_SIZE) == 0) { /* TODO check generation of extent */ -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html