[linux-lvm] lvcreate segfault in vg_setup_pointers_for_snapshots

Joe Thornber thornber at btconnect.com
Thu Oct 4 11:05:03 UTC 2001


On Thu, Oct 04, 2001 at 11:31:15AM +0100, Paul Jakma wrote:
> ok... looking at tools/lib/vg_setup_pointers_for_snapshots():
> 
>  if ( vg == NULL) goto vg_setup_pointers_for_snapshots_end;
>    for ( l = 0; l < vg->lv_max; l++) {
>       lv_t *lv_chain_ptr = vg->lv[l];
>       if ( lv_chain_ptr == NULL) continue;
>       if ( lv_chain_ptr->lv_access & LV_SNAPSHOT_ORG) {
> 
> isn't this a wee bit suspect? we test for NULL /after/ the assignment, 
> and continue anyway? next line deferences that pointer, irregardless 
> of the test for previously..

No, this snippet looks right to me.  How can we test before the assignment ?
If lv_chain_ptr is NULL the code then jumps back to the top of the 'for' loop.

- Joe




More information about the linux-lvm mailing list