Windows: buf_CleanLocked protect against NULL bp->userp

The cm_buf_t.userp field should never be NULL if the CM_BUF_DIRTY
flag is set but apparently it sometimes is.  cm_BufWrite() requires
that the userp parameter be non-NULL.  Otherwise, an assertion fails
and afsd_service.exe panics.  If bp->userp is NULL, use cm_rootUserp.
The worst that will happen is the write will fail due to an access
denied error.

Reviewed-on: http://gerrit.openafs.org/8475
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
(cherry picked from commit f436fe03c8)

Change-Id: I33f5e73509cc2c6517ae4bf4214011383a341411
Reviewed-on: http://gerrit.openafs.org/8649
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
This commit is contained in:
Jeffrey Altman 2012-11-17 21:44:52 -05:00
parent c95d1aee53
commit ad7cfa94e6

View File

@ -765,9 +765,8 @@ afs_uint32 buf_CleanLocked(cm_scache_t *scp, cm_buf_t *bp, cm_req_t *reqp,
* to determine if it is appropriate to fill a full chunk of data * to determine if it is appropriate to fill a full chunk of data
* when storing to the file server. * when storing to the file server.
*/ */
code = (*cm_buf_opsp->Writep)(scp, &offset, code = (*cm_buf_opsp->Writep)(scp, &offset, bp->dirty_length, flags,
bp->dirty_length, bp->userp ? bp->userp : cm_rootUserp, reqp);
flags, bp->userp, reqp);
osi_Log3(buf_logp, "buf_CleanLocked I/O on scp 0x%p buf 0x%p, done=%d", scp, bp, code); osi_Log3(buf_logp, "buf_CleanLocked I/O on scp 0x%p buf 0x%p, done=%d", scp, bp, code);
} }
lock_ObtainMutex(&bp->mx); lock_ObtainMutex(&bp->mx);