Message ID | 517A6DAE.7010604@inktank.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Reviewed-by: Josh Durgin <josh.durgin@inktank.com> On 04/26/2013 05:06 AM, Alex Elder wrote: > Change rbd_dev_v2_snap_info() so it only ever sets values of the > size and features parameters if looking up the snapshot name was > successful. > > Signed-off-by: Alex Elder <elder@inktank.com> > --- > drivers/block/rbd.c | 24 +++++++++++++++++++----- > 1 file changed, 19 insertions(+), 5 deletions(-) > > diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c > index 1e01f0d..e7d10d3 100644 > --- a/drivers/block/rbd.c > +++ b/drivers/block/rbd.c > @@ -3908,6 +3908,7 @@ static char *rbd_dev_v2_snap_name(struct > rbd_device *rbd_dev, u32 which) > if (!reply_buf) > return ERR_PTR(-ENOMEM); > > + rbd_assert(which < rbd_dev->header.snapc->num_snaps); > snap_id = cpu_to_le64(rbd_dev->header.snapc->snaps[which]); > ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name, > "rbd", "get_snapshot_name", > @@ -3940,17 +3941,30 @@ static char *rbd_dev_v2_snap_info(struct > rbd_device *rbd_dev, u32 which, > u64 *snap_size, u64 *snap_features) > { > u64 snap_id; > + u64 size; > + u64 features; > + char *snap_name; > int ret; > > + rbd_assert(which < rbd_dev->header.snapc->num_snaps); > snap_id = rbd_dev->header.snapc->snaps[which]; > - ret = _rbd_dev_v2_snap_size(rbd_dev, snap_id, NULL, snap_size); > + ret = _rbd_dev_v2_snap_size(rbd_dev, snap_id, NULL, &size); > if (ret) > - return ERR_PTR(ret); > - ret = _rbd_dev_v2_snap_features(rbd_dev, snap_id, snap_features); > + goto out_err; > + > + ret = _rbd_dev_v2_snap_features(rbd_dev, snap_id, &features); > if (ret) > - return ERR_PTR(ret); > + goto out_err; > + > + snap_name = rbd_dev_v2_snap_name(rbd_dev, which); > + if (!IS_ERR(snap_name)) { > + *snap_size = size; > + *snap_features = features; > + } > > - return rbd_dev_v2_snap_name(rbd_dev, which); > + return snap_name; > +out_err: > + return ERR_PTR(ret); > } > > static char *rbd_dev_snap_info(struct rbd_device *rbd_dev, u32 which, > -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 1e01f0d..e7d10d3 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3908,6 +3908,7 @@ static char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, u32 which) if (!reply_buf) return ERR_PTR(-ENOMEM); + rbd_assert(which < rbd_dev->header.snapc->num_snaps); snap_id = cpu_to_le64(rbd_dev->header.snapc->snaps[which]); ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name,
Change rbd_dev_v2_snap_info() so it only ever sets values of the size and features parameters if looking up the snapshot name was successful. Signed-off-by: Alex Elder <elder@inktank.com> --- drivers/block/rbd.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) "rbd", "get_snapshot_name", @@ -3940,17 +3941,30 @@ static char *rbd_dev_v2_snap_info(struct rbd_device *rbd_dev, u32 which, u64 *snap_size, u64 *snap_features) { u64 snap_id; + u64 size; + u64 features; + char *snap_name; int ret; + rbd_assert(which < rbd_dev->header.snapc->num_snaps); snap_id = rbd_dev->header.snapc->snaps[which]; - ret = _rbd_dev_v2_snap_size(rbd_dev, snap_id, NULL, snap_size); + ret = _rbd_dev_v2_snap_size(rbd_dev, snap_id, NULL, &size); if (ret) - return ERR_PTR(ret); - ret = _rbd_dev_v2_snap_features(rbd_dev, snap_id, snap_features); + goto out_err; + + ret = _rbd_dev_v2_snap_features(rbd_dev, snap_id, &features); if (ret) - return ERR_PTR(ret); + goto out_err; + + snap_name = rbd_dev_v2_snap_name(rbd_dev, which); + if (!IS_ERR(snap_name)) { + *snap_size = size; + *snap_features = features; + } - return rbd_dev_v2_snap_name(rbd_dev, which); + return snap_name; +out_err: + return ERR_PTR(ret); } static char *rbd_dev_snap_info(struct rbd_device *rbd_dev, u32 which,