From: pankaj kumar biswas Subject: "Unable to save Login Script" appears when trying to save a user login script References: bnc#638985 Patch-mainline: No Certain calls like SetFileSize do not have any payload associated with the request. All the needed information are passed along just as headers. So the minimum fragment size can be zero. Make code handle that. Signed-off-by: Sankar P Signed-off-by: Pankaj Biswas Reported-by: Jeremy Meldrum Index: linux-3.0-rc3-master/fs/novfs/nwcapi.h =================================================================== --- linux-3.0-rc3-master.orig/fs/novfs/nwcapi.h +++ linux-3.0-rc3-master/fs/novfs/nwcapi.h @@ -298,11 +298,19 @@ N_EXTERN_LIBRARY(NWRCODE) #define MAX_NAME_LEN 1024 #define MAX_NUM_REPLIES 4096 -#define MIN_NUM_REPLIES 1 +/* + * MIN_NUM_REPLIES should be zero,as some calls like ScanSalvagableFiles are asynchronous. + * The server will not be sending responses to these requests. + */ +#define MIN_NUM_REPLIES 0 #define MAX_NUM_REQUESTS 4096 #define MIN_NUM_REQUESTS 1 #define MAX_FRAG_SIZE 65536 -#define MIN_FRAG_SIZE 1 +/* + * Certain calls like SetFileSize do not have any payload associated with the request. + * All the needed information are passed along just as headers.So the minimum fragment size can be zero. + */ +#define MIN_FRAG_SIZE 0 #define MAX_INFO_LEN 4096 #define MAX_DOMAIN_LEN MAX_NETWORK_NAME_LENGTH #define MAX_OFFSET_LEN 4096 Index: linux-3.0-rc3-master/fs/novfs/nwcapi.c =================================================================== --- linux-3.0-rc3-master.orig/fs/novfs/nwcapi.c +++ linux-3.0-rc3-master/fs/novfs/nwcapi.c @@ -274,28 +274,30 @@ int novfs_raw_send(struct novfs_xplat *p /* * Figure out the length of the request */ - frag = kmalloc(xRequest.uNumReplyFrags * sizeof(struct nwc_frag), GFP_KERNEL); + totalLen = 0; + if(xRequest.uNumReplyFrags) { + frag = kmalloc(xRequest.uNumReplyFrags * sizeof(struct nwc_frag), GFP_KERNEL); - DbgPrint("[XPLAT RawNCP] - Reply Frag Count 0x%X", xRequest.uNumReplyFrags); + DbgPrint("[XPLAT RawNCP] - Reply Frag Count 0x%X", xRequest.uNumReplyFrags); - if (!frag) - return -ENOMEM; + if (!frag) + return -ENOMEM; - if(copy_from_user(frag, xRequest.pReplyFrags, xRequest.uNumReplyFrags * sizeof(struct nwc_frag))) { - retCode = -EFAULT; - goto out_frag; - } - totalLen = 0; - - cFrag = frag; - for (x = 0; x < xRequest.uNumReplyFrags; x++) { - DbgPrint("[XPLAT - RawNCP] - Frag Len = %d", cFrag->uLength); - if (cFrag->uLength > MAX_FRAG_SIZE || cFrag->uLength < MIN_FRAG_SIZE) { - retCode = -EINVAL; - goto out; + if(copy_from_user(frag, xRequest.pReplyFrags, xRequest.uNumReplyFrags * sizeof(struct nwc_frag))) { + retCode = -EFAULT; + goto out_frag; } - totalLen += cFrag->uLength; - cFrag++; + + cFrag = frag; + for (x = 0; x < xRequest.uNumReplyFrags; x++) { + DbgPrint("[XPLAT - RawNCP] - Frag Len = %d", cFrag->uLength); + if (cFrag->uLength > MAX_FRAG_SIZE || cFrag->uLength < MIN_FRAG_SIZE) { + retCode = -EINVAL; + goto out; + } + totalLen += cFrag->uLength; + cFrag++; + } } DbgPrint("[XPLAT - RawNCP] - totalLen = %d", totalLen);