[RHEL7,COMMIT] ploop: variable dereferenced before check 'fbd' in ploop_fb_get_reloc_block

Submitted by Konstantin Khorenko on June 1, 2020, 11:28 a.m.

Details

Message ID 202006011128.051BSHgZ024978@finist-ce7.sw.ru
State New
Series "ploop: variable dereferenced before check 'fbd' in ploop_fb_get_reloc_block"
Headers show

Commit Message

Konstantin Khorenko June 1, 2020, 11:28 a.m.
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.151.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.151.9
------>
commit bd62a6712a2ac2b62b49805d5a97a96469c00fa4
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Mon Jun 1 14:28:17 2020 +0300

    ploop: variable dereferenced before check 'fbd' in ploop_fb_get_reloc_block
    
    found by smatch:
    drivers/block/ploop/freeblks.c:469 ploop_fb_get_reloc_block() warn:
     variable dereferenced before check 'fbd' (see line 467)
    
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/freeblks.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/freeblks.c b/drivers/block/ploop/freeblks.c
index e210421efa8b0..7a06b09a8e7df 100644
--- a/drivers/block/ploop/freeblks.c
+++ b/drivers/block/ploop/freeblks.c
@@ -464,11 +464,12 @@  int ploop_fb_get_reloc_block(struct ploop_freeblks_desc *fbd,
 	cluster_t from_clu, to_clu;
 	iblock_t  from_iblk, to_iblk;
 	u32 free;
-	struct ploop_relocblks_extent *r_extent = fbd->fbd_lrb.ext;
+	struct ploop_relocblks_extent *r_extent;
 
 	if (!fbd)
 		return -1;
 
+	r_extent = fbd->fbd_lrb.ext;
 	/* whole range is drained? */
 	if (r_extent == NULL)
 		return -1;