mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
cephfs: free resources when newVolumeOptionsFromVolID() errors out
The allocated, and potentially connected, volumeOptions object in newVolumeOptionsFromVolID() is not cleaned-up in case of errors. This could cause resource leaks. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
0f9087d05e
commit
0e96199a1c
@ -282,6 +282,13 @@ func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secret
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
// in case of an error, volOptions is not returned, release any
|
||||||
|
// resources that may have been allocated
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
volOptions.Destroy()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
volOptions.FsName, err = volOptions.getFsName(ctx)
|
volOptions.FsName, err = volOptions.getFsName(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user