mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +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 {
|
||||
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)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user