From 422edc2d3498e65efb6d0e786f9f730ca07d697a Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Mon, 16 Oct 2023 17:56:54 -0600 Subject: [PATCH] Fix session leak in Dell provider: This was leaving open sessions in non Dell machines. Closed sessions when the Dell Open function returns error after successfully opening. Signed-off-by: Jacob Weinstock --- providers/dell/idrac.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/providers/dell/idrac.go b/providers/dell/idrac.go index 8535026c..27b7c987 100644 --- a/providers/dell/idrac.go +++ b/providers/dell/idrac.go @@ -128,10 +128,16 @@ func (c *Conn) Open(ctx context.Context) (err error) { // is available across various BMC vendors, we verify the device we're connected to is dell. manufacturer, err := c.deviceManufacturer(ctx) if err != nil { + if er := c.redfishwrapper.Close(ctx); er != nil { + return fmt.Errorf("%v: %w", err, er) + } return err } if !strings.Contains(strings.ToLower(manufacturer), common.VendorDell) { + if er := c.redfishwrapper.Close(ctx); er != nil { + return fmt.Errorf("%v: %w", err, er) + } return bmclibErrs.ErrIncompatibleProvider }