snapd: Missing Unlock before return in package daemon, func sysInfo

Bug #1737427 reported by Lars Tørnes Hansen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snappy
Fix Released
Undecided
Maciej Borzecki

Bug Description

In snapd in package daemon in func sysInfo in api.go :

Before line 272 : https://github.com/snapcore/snapd/blob/e50b4afebb83eee409dc2254290b8ef1eeaa394b/daemon/api.go#L272

... a st.Unlock() is missing before returning the error

code:

L267 st.Lock()
L268 nextRefresh := snapMgr.NextRefresh()
L269 lastRefresh, _ := snapMgr.LastRefresh()
L270 refreshScheduleStr, err := snapMgr.RefreshSchedule()
L271 if err != nil {
L272 return InternalError("cannot get refresh schedule: %s", err)
L273 }
L274 users, err := auth.Users(st)
L275 st.Unlock()

I must admit that I had not looked deeper into the code, I was just reading source code, and the missing st.Unlock is necessary to release the resource.

Revision history for this message
Maciej Borzecki (maciek-borzecki) wrote :

Thanks for the report. I've opened a PR addressing this: https://github.com/snapcore/snapd/pull/4520

Changed in snappy:
status: New → In Progress
assignee: nobody → Maciej Borzecki (maciek-borzecki)
Changed in snappy:
status: In Progress → Fix Committed
Changed in snappy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.