From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
Steve French <sfrench@samba.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/8] CIFS: Delete 11 error messages for a failed memory allocation
Date: Sun, 20 Aug 2017 18:33:55 +0200 [thread overview]
Message-ID: <3b4ecd79-ac00-9aa6-ae3e-2f153525214a@users.sourceforge.net> (raw)
In-Reply-To: <826310e5-e01c-38af-90df-c5630f761a4d@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 20 Aug 2017 14:35:36 +0200
Omit extra messages for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/cifs/connect.c | 17 ++++-------------
fs/cifs/sess.c | 7 ++-----
fs/cifs/smb2ops.c | 1 -
fs/cifs/smb2pdu.c | 6 ------
fs/cifs/smb2transport.c | 1 -
5 files changed, 6 insertions(+), 26 deletions(-)
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 59647eb72c5f..b67a3c132a8f 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1737,10 +1737,8 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
/* Now build new password string */
temp_len = strlen(value);
vol->password = kzalloc(temp_len+1, GFP_KERNEL);
- if (vol->password == NULL) {
- pr_warn("CIFS: no memory for password\n");
+ if (!vol->password)
goto cifs_parse_mount_err;
- }
for (i = 0, j = 0; i < temp_len; i++, j++) {
vol->password[j] = value[i];
@@ -1780,10 +1778,9 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
kfree(vol->domainname);
vol->domainname = kstrdup(string, GFP_KERNEL);
- if (!vol->domainname) {
- pr_warn("CIFS: no memory for domainname\n");
+ if (!vol->domainname)
goto cifs_parse_mount_err;
- }
+
cifs_dbg(FYI, "Domain name set\n");
break;
case Opt_srcaddr:
@@ -1813,10 +1810,8 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
kfree(vol->iocharset);
vol->iocharset = kstrdup(string,
GFP_KERNEL);
- if (!vol->iocharset) {
- pr_warn("CIFS: no memory for charset\n");
+ if (!vol->iocharset)
goto cifs_parse_mount_err;
- }
}
/* if iocharset not set then load_nls_default
* is used by caller
@@ -2494,8 +2489,6 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses)
vol->username = kstrndup(payload, len, GFP_KERNEL);
if (!vol->username) {
- cifs_dbg(FYI, "Unable to allocate %zd bytes for username\n",
- len);
rc = -ENOMEM;
goto out_key_put;
}
@@ -2513,8 +2506,6 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses)
++delim;
vol->password = kstrndup(delim, len, GFP_KERNEL);
if (!vol->password) {
- cifs_dbg(FYI, "Unable to allocate %zd bytes for password\n",
- len);
rc = -ENOMEM;
kfree(vol->username);
vol->username = NULL;
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 8b0502cd39af..2fb36bbaf5b0 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -317,10 +317,9 @@ 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");
+ if (!ses->auth_key.response)
return -ENOMEM;
- }
+
ses->auth_key.len = tilen;
}
@@ -1048,8 +1047,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",
- msg->sesskey_len);
rc = -ENOMEM;
goto out_put_spnego_key;
}
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index cfacf2c97e94..783b5d263704 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -1988,7 +1988,6 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc)
iv_len = crypto_aead_ivsize(tfm);
iv = kzalloc(iv_len, GFP_KERNEL);
if (!iv) {
- cifs_dbg(VFS, "%s: Failed to alloc IV", __func__);
rc = -ENOMEM;
goto free_sg;
}
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 5fb2fc2d0080..668732e6f80f 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -851,9 +851,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",
- msg->sesskey_len);
rc = -ENOMEM;
goto out_put_spnego_key;
}
@@ -2122,9 +2119,6 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
if (!*data) {
*data = kmalloc(*dlen, GFP_KERNEL);
if (!*data) {
- cifs_dbg(VFS,
- "Error %d allocating memory for acl\n",
- rc);
*dlen = 0;
goto qinf_exit;
}
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
index 67367cf1f8cd..abfcc759e75d 100644
--- a/fs/cifs/smb2transport.c
+++ b/fs/cifs/smb2transport.c
@@ -100,7 +100,6 @@ smb3_crypto_shash_allocate(struct TCP_Server_Info *server)
crypto_shash_descsize(server->secmech.cmacaes);
server->secmech.sdesccmacaes = kmalloc(size, GFP_KERNEL);
if (!server->secmech.sdesccmacaes) {
- cifs_dbg(VFS, "%s: Can't alloc cmacaes\n", __func__);
kfree(server->secmech.sdeschmacsha256);
server->secmech.sdeschmacsha256 = NULL;
crypto_free_shash(server->secmech.hmacsha256);
--
2.14.0
next prev parent reply other threads:[~2017-08-20 16:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-20 16:32 [PATCH 0/8] CIFS: Adjustments for several function implementations SF Markus Elfring
2017-08-20 16:33 ` SF Markus Elfring [this message]
[not found] ` <826310e5-e01c-38af-90df-c5630f761a4d-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-08-20 16:35 ` [PATCH 2/8] CIFS: Improve 27 size determinations SF Markus Elfring
2017-08-20 16:36 ` [PATCH 3/8] CIFS: One function call less in cifs_lookup() after error detection SF Markus Elfring
2017-08-20 16:40 ` [PATCH 6/8] CIFS: Return directly after a failed build_path_from_dentry() in cifs_do_create() SF Markus Elfring
2019-11-07 3:34 ` Steve French
2017-08-20 16:38 ` [PATCH 4/8] CIFS: Use common error handling code in cifs_mknod() SF Markus Elfring
2017-08-20 16:39 ` [PATCH 5/8] CIFS: Less function calls in cifs_mknod() after error detection SF Markus Elfring
2017-08-20 16:41 ` [PATCH 7/8] CIFS: Delete an unnecessary variable initialisation in cifs_do_create() SF Markus Elfring
2017-08-20 16:42 ` [PATCH 8/8] CIFS: One function call less in cifs_do_create() after error detection SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3b4ecd79-ac00-9aa6-ae3e-2f153525214a@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox