cifs: remove unnecessary oom message
Subsystems (2)
PATCH 1/1 cifs: remove unnecessary oom message
Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message
Remove it can help us save a bit of memory.
--- fs/cifs/cifsencrypt.c | 4 +--- fs/cifs/connect.c | 6 +----- fs/cifs/sess.c | 6 +----- fs/cifs/smb2pdu.c | 2 -- 4 files changed, 3 insertions(+), 15 deletions(-)
fs/cifs/cifsencrypt.c +1 -3
@@ -787,10 +787,8 @@ calc_seckey(struct cifs_ses *ses)get_random_bytes (sec_key,CIFS_SESS_KEY_SIZE ); ctx_arc4 =kmalloc (sizeof (*ctx_arc4),GFP_KERNEL ); -if (!ctx_arc4) { -cifs_dbg (VFS ,"Could not allocate arc4 context\n" ); +if (!ctx_arc4)return -ENOMEM ; - }arc4_setkey (ctx_arc4, ses->auth_key.response,CIFS_SESS_KEY_SIZE ); arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key,
fs/cifs/connect.c +1 -5
@@ -97,10 +97,8 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server) len =strlen (server->hostname) +3 ; unc =kmalloc (len,GFP_KERNEL ); -if (!unc) { -cifs_dbg (FYI ,"%s: failed to create UNC path\n" , __func__); +if (!unc)return -ENOMEM ; - }scnprintf (unc, len,"\\\\%s" , server->hostname); rc =dns_resolve_server_name_to_ip (unc, &ipaddr);
@@ -1758,8 +1756,6 @@ cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses)if (is_domain && ses->domainName) { ctx->domainname =kstrdup (ses->domainName,GFP_KERNEL );if (!ctx->domainname) { -cifs_dbg (FYI ,"Unable to allocate %zd bytes for domain\n" , - len); rc = -ENOMEM ;kfree (ctx->username); ctx->username =NULL ;
fs/cifs/sess.c +1 -5
@@ -602,10 +602,8 @@ int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,if (tilen) { ses->auth_key.response =kmemdup (bcc_ptr + tioffset, tilen,GFP_KERNEL ); -if (!ses->auth_key.response) { -cifs_dbg (VFS ,"Challenge target info alloc failure\n" ); +if (!ses->auth_key.response)return -ENOMEM ; - } ses->auth_key.len = tilen; }
@@ -1338,8 +1336,6 @@ sess_auth_kerberos(struct sess_data *sess_data) ses->auth_key.response =kmemdup (msg->data, msg->sesskey_len,GFP_KERNEL );if (!ses->auth_key.response) { -cifs_dbg (VFS ,"Kerberos can't allocate (%u bytes) memory\n" , - msg->sesskey_len); rc = -ENOMEM ; goto out_put_spnego_key; }
fs/cifs/smb2pdu.c +0 -2
@@ -1355,8 +1355,6 @@ SMB2_auth_kerberos(struct SMB2_sess_data *sess_data) ses->auth_key.response =kmemdup (msg->data, msg->sesskey_len,GFP_KERNEL );if (!ses->auth_key.response) { -cifs_dbg (VFS ,"Kerberos can't allocate (%u bytes) memory\n" , - msg->sesskey_len); rc = -ENOMEM ; goto out_put_spnego_key; }
Signature · 1 line
2.25.1
I am curious the motivation for these - I agree that removing the debug messages saves (albeit trivial amount of) memory but curious about how other areas of the kernel handle logging low memory/out of memory issues?
Quoted 97 lines · Zhen Lei
Fixes
scripts/checkpatch.plwarning:
WARNING: Possible unnecessary 'out of memory' messageRemove it can help us save a bit of memory.
Signed-off-by Zhen Lei <[email protected]>--- fs/cifs/cifsencrypt.c | 4 +--- fs/cifs/connect.c | 6 +----- fs/cifs/sess.c | 6 +----- fs/cifs/smb2pdu.c | 2 -- 4 files changed, 3 insertions(+), 15 deletions(-)fs/cifs/cifsencrypt.c +1
-3@@ -787,10 +787,8 @@ calc_seckey(struct cifs_ses *ses)get_random_bytes (sec_key,CIFS_SESS_KEY_SIZE ); ctx_arc4 =kmalloc (sizeof (*ctx_arc4),GFP_KERNEL ); -if (!ctx_arc4) { -cifs_dbg (VFS ,"Could not allocate arc4 context\n" ); +if (!ctx_arc4)return -ENOMEM ; - }arc4_setkey (ctx_arc4, ses->auth_key.response,CIFS_SESS_KEY_SIZE ); arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key,fs/cifs/connect.c +1
-5@@ -97,10 +97,8 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server) len =strlen (server->hostname) +3 ; unc =kmalloc (len,GFP_KERNEL ); -if (!unc) { -cifs_dbg (FYI ,"%s: failed to create UNC path\n" , __func__); +if (!unc)return -ENOMEM ; - }scnprintf (unc, len,"\\\\%s" , server->hostname); rc =dns_resolve_server_name_to_ip (unc, &ipaddr);@@ -1758,8 +1756,6 @@ cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses)if (is_domain && ses->domainName) { ctx->domainname =kstrdup (ses->domainName,GFP_KERNEL );if (!ctx->domainname) { -cifs_dbg (FYI ,"Unable to allocate %zd bytes for domain\n" , - len); rc = -ENOMEM ;kfree (ctx->username); ctx->username =NULL ;fs/cifs/sess.c +1
-5@@ -602,10 +602,8 @@ int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,if (tilen) { ses->auth_key.response =kmemdup (bcc_ptr + tioffset, tilen,GFP_KERNEL ); -if (!ses->auth_key.response) { -cifs_dbg (VFS ,"Challenge target info alloc failure\n" ); +if (!ses->auth_key.response)return -ENOMEM ; - } ses->auth_key.len = tilen; }@@ -1338,8 +1336,6 @@ sess_auth_kerberos(struct sess_data *sess_data) ses->auth_key.response =kmemdup (msg->data, msg->sesskey_len,GFP_KERNEL );if (!ses->auth_key.response) { -cifs_dbg (VFS ,"Kerberos can't allocate (%u bytes) memory\n" , - msg->sesskey_len); rc = -ENOMEM ; goto out_put_spnego_key; }fs/cifs/smb2pdu.c +0
-3@@ -1355,8 +1355,6 @@ SMB2_auth_kerberos(struct SMB2_sess_data *sess_data) ses->auth_key.response =kmemdup (msg->data, msg->sesskey_len,GFP_KERNEL );if (!ses->auth_key.response) { -cifs_dbg (VFS ,"Kerberos can't allocate (%u bytes) memory\n" , - msg->sesskey_len); rc = -ENOMEM ; goto out_put_spnego_key; } --2.25.1
Signature · 3 lines
Thanks, Steve
Quoted 4 lines · Steve French
I am curious the motivation for these - I agree that removing the debug messages saves (albeit trivial amount of) memory but curious about how other areas of the kernel handle logging low memory/out of memory issues?
$ scripts/checkpatch.pl --types=OOM_MESSAGE -- $(git ls-files kernel/) > err.txt $ cat err.txt | grep WARNING | wc -l 12
$ git grep -wn k.alloc kernel/ | wc -l 469 $ git grep -wn kstrdup kernel/ | wc -l 88 ... ... Other kernel memory allocation APIs are omitted.
You see, the vast majority are not printed.
Quoted 101 lines · Zhen Lei
Quoted 97 lines
Fixes
scripts/checkpatch.plwarning:
WARNING: Possible unnecessary 'out of memory' messageRemove it can help us save a bit of memory.
Signed-off-by Zhen Lei <[email protected]>--- fs/cifs/cifsencrypt.c | 4 +--- fs/cifs/connect.c | 6 +----- fs/cifs/sess.c | 6 +----- fs/cifs/smb2pdu.c | 2 -- 4 files changed, 3 insertions(+), 15 deletions(-)fs/cifs/cifsencrypt.c +1
-3@@ -787,10 +787,8 @@ calc_seckey(struct cifs_ses *ses)get_random_bytes (sec_key,CIFS_SESS_KEY_SIZE ); ctx_arc4 =kmalloc (sizeof (*ctx_arc4),GFP_KERNEL ); -if (!ctx_arc4) { -cifs_dbg (VFS ,"Could not allocate arc4 context\n" ); +if (!ctx_arc4)return -ENOMEM ; - }arc4_setkey (ctx_arc4, ses->auth_key.response,CIFS_SESS_KEY_SIZE ); arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key,fs/cifs/connect.c +1
-5@@ -97,10 +97,8 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server) len =strlen (server->hostname) +3 ; unc =kmalloc (len,GFP_KERNEL ); -if (!unc) { -cifs_dbg (FYI ,"%s: failed to create UNC path\n" , __func__); +if (!unc)return -ENOMEM ; - }scnprintf (unc, len,"\\\\%s" , server->hostname); rc =dns_resolve_server_name_to_ip (unc, &ipaddr);@@ -1758,8 +1756,6 @@ cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses)if (is_domain && ses->domainName) { ctx->domainname =kstrdup (ses->domainName,GFP_KERNEL );if (!ctx->domainname) { -cifs_dbg (FYI ,"Unable to allocate %zd bytes for domain\n" , - len); rc = -ENOMEM ;kfree (ctx->username); ctx->username =NULL ;fs/cifs/sess.c +1
-5@@ -602,10 +602,8 @@ int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,if (tilen) { ses->auth_key.response =kmemdup (bcc_ptr + tioffset, tilen,GFP_KERNEL ); -if (!ses->auth_key.response) { -cifs_dbg (VFS ,"Challenge target info alloc failure\n" ); +if (!ses->auth_key.response)return -ENOMEM ; - } ses->auth_key.len = tilen; }@@ -1338,8 +1336,6 @@ sess_auth_kerberos(struct sess_data *sess_data) ses->auth_key.response =kmemdup (msg->data, msg->sesskey_len,GFP_KERNEL );if (!ses->auth_key.response) { -cifs_dbg (VFS ,"Kerberos can't allocate (%u bytes) memory\n" , - msg->sesskey_len); rc = -ENOMEM ; goto out_put_spnego_key; }fs/cifs/smb2pdu.c +0
-3@@ -1355,8 +1355,6 @@ SMB2_auth_kerberos(struct SMB2_sess_data *sess_data) ses->auth_key.response =kmemdup (msg->data, msg->sesskey_len,GFP_KERNEL );if (!ses->auth_key.response) { -cifs_dbg (VFS ,"Kerberos can't allocate (%u bytes) memory\n" , - msg->sesskey_len); rc = -ENOMEM ; goto out_put_spnego_key; } --2.25.1