mirror of
https://github.com/NVIDIA/open-gpu-kernel-modules.git
synced 2025-03-14 09:29:24 +01:00
Fix kernel memory leak in pNotifShare
This commit is contained in:
parent
e45d91de02
commit
bd90c1b478
@ -395,7 +395,6 @@ eventInit_IMPL
|
||||
*pppEventNotification = inotifyGetNotificationListPtr(pNotifierShare->pNotifier);
|
||||
}
|
||||
|
||||
serverRefShare(&g_resServ, staticCast(pNotifierShare, RsShared));
|
||||
pEvent->pNotifierShare = pNotifierShare;
|
||||
|
||||
// RS-TODO these can be looked up from share
|
||||
@ -427,6 +426,7 @@ notifyGetOrAllocNotifShare_IMPL
|
||||
if (pNotifierShare == NULL)
|
||||
{
|
||||
RsShared *pShare;
|
||||
// serverAllocShare() sets pNotifierShare->refCount to 1.
|
||||
status = serverAllocShare(&g_resServ, classInfo(NotifShare), &pShare);
|
||||
if (status != NV_OK)
|
||||
return status;
|
||||
@ -437,6 +437,14 @@ notifyGetOrAllocNotifShare_IMPL
|
||||
pNotifierShare->hNotifierResource = hNotifierResource;
|
||||
inotifySetNotificationShare(staticCast(pNotifier, INotifier), pNotifierShare);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Move serverRefShare() from eventInit_IMPL to here, so that |pNotifierShare|
|
||||
// can be refcounted correctly.
|
||||
//
|
||||
// serverRefShare() increments pNotifierShare->refCount.
|
||||
serverRefShare(&g_resServ, staticCast(pNotifierShare, RsShared));
|
||||
}
|
||||
|
||||
if (ppNotifierShare)
|
||||
*ppNotifierShare = pNotifierShare;
|
||||
|
@ -1109,4 +1109,10 @@ shrnotifDestruct_IMPL
|
||||
NotifShare *pNotifShare
|
||||
)
|
||||
{
|
||||
// pNotifier->pNotifierShare should be set to NULL, or inotifyGetNotificationShare() would
|
||||
// return invalid/wild pointer and cause kernel crash.
|
||||
if (pNotifShare->pNotifier != NULL)
|
||||
{
|
||||
inotifySetNotificationShare(pNotifShare->pNotifier, NULL);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user