Showing error 795

User: Jiri Slaby
Error type: Memory Leak
Error type description: There the code omits to free some allocated memory
File location: fs/nfs/nfs4proc.c
Line in file: 1320
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Entered: 2011-11-07 22:26:27 UTC


Source:

1290/* 
1291 * It is possible for data to be read/written from a mem-mapped file 
1292 * after the sys_close call (which hits the vfs layer as a flush).
1293 * This means that we can't safely call nfsv4 close on a file until 
1294 * the inode is cleared. This in turn means that we are not good
1295 * NFSv4 citizens - we do not indicate to the server to update the file's 
1296 * share state even when we are done with one of the three share 
1297 * stateid's in the inode.
1298 *
1299 * NOTE: Caller must be holding the sp->so_owner semaphore!
1300 */
1301int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait)
1302{
1303        struct nfs_server *server = NFS_SERVER(state->inode);
1304        struct nfs4_closedata *calldata;
1305        struct nfs4_state_owner *sp = state->owner;
1306        struct rpc_task *task;
1307        struct rpc_message msg = {
1308                .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE],
1309                .rpc_cred = state->owner->so_cred,
1310        };
1311        struct rpc_task_setup task_setup_data = {
1312                .rpc_client = server->client,
1313                .rpc_message = &msg,
1314                .callback_ops = &nfs4_close_ops,
1315                .workqueue = nfsiod_workqueue,
1316                .flags = RPC_TASK_ASYNC,
1317        };
1318        int status = -ENOMEM;
1319
1320        calldata = kmalloc(sizeof(*calldata), GFP_KERNEL);
1321        if (calldata == NULL)
1322                goto out;
1323        calldata->inode = state->inode;
1324        calldata->state = state;
1325        calldata->arg.fh = NFS_FH(state->inode);
1326        calldata->arg.stateid = &state->open_stateid;
1327        /* Serialization for the sequence id */
1328        calldata->arg.seqid = nfs_alloc_seqid(&state->owner->so_seqid);
1329        if (calldata->arg.seqid == NULL)
1330                goto out_free_calldata;
Show full sources