diff --git a/pkg/lisafs/handlers.go b/pkg/lisafs/handlers.go index cb7167bb7..9f3f9c1c6 100644 --- a/pkg/lisafs/handlers.go +++ b/pkg/lisafs/handlers.go @@ -892,6 +892,7 @@ func LinkAtHandler(c *Connection, comm Communicator, payloadLen uint32) (uint32, if err != nil { return 0, err } + defer targetFD.DecRef(nil) if targetFD.IsDir() { // Can not create hard link to directory. return 0, unix.EPERM diff --git a/pkg/lisafs/testsuite/testsuite.go b/pkg/lisafs/testsuite/testsuite.go index e9815baa2..0ae4db28d 100644 --- a/pkg/lisafs/testsuite/testsuite.go +++ b/pkg/lisafs/testsuite/testsuite.go @@ -490,7 +490,8 @@ func testHardLink(ctx context.Context, t *testing.T, tester Tester, root lisafs. defer closeFD(ctx, t, fd) defer unix.Close(hostFD) - link, linkStat := link(ctx, t, root, name, controlFile) + linkName := "linkFile" + link, linkStat := link(ctx, t, root, linkName, controlFile) defer closeFD(ctx, t, link) if linkStat.Ino != fileIno.Ino {