From: SF Markus Elfring <elfring@users.sourceforge.net>
To: Anton Vorontsov <anton@enomsg.org>,
Colin Cross <ccross@android.com>,
Kees Cook <keescook@chromium.org>,
Tony Luck <tony.luck@intel.com>,
kernel-janitors@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] pstore: Improve a size determination in three functions
Date: Wed, 16 Aug 2017 19:22:32 +0000 [thread overview]
Message-ID: <23798ef4-5559-3454-ecf4-e6844b644ff3@users.sourceforge.net> (raw)
In-Reply-To: <97737d95-d6aa-d24f-1af0-9d4895ceaed2@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 16 Aug 2017 20:50:15 +0200
Replace the specification of data types by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/pstore/ram.c | 3 +--
fs/pstore/ram_core.c | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 42d27e5fac9f..0ef95c384bed 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -293,8 +293,7 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record)
*/
struct persistent_ram_zone *tmp_prz, *prz_next;
- tmp_prz = kzalloc(sizeof(struct persistent_ram_zone),
- GFP_KERNEL);
+ tmp_prz = kzalloc(sizeof(*tmp_prz), GFP_KERNEL);
if (!tmp_prz)
return -ENOMEM;
free_prz = true;
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index fafa8af1289c..5d9f7280d757 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -405,7 +405,7 @@ static void *persistent_ram_vmap(phys_addr_t start, size_t size,
else
prot = pgprot_writecombine(PAGE_KERNEL);
- pages = kmalloc_array(page_count, sizeof(struct page *), GFP_KERNEL);
+ pages = kmalloc_array(page_count, sizeof(*pages), GFP_KERNEL);
if (!pages)
return NULL;
@@ -520,7 +520,7 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
struct persistent_ram_zone *prz;
int ret = -ENOMEM;
- prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL);
+ prz = kzalloc(sizeof(*prz), GFP_KERNEL);
if (!prz)
goto err;
--
2.14.0
next prev parent reply other threads:[~2017-08-16 19:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 19:20 [PATCH 0/3] pstore: Adjustments for some function implementations SF Markus Elfring
2017-08-16 19:21 ` [PATCH 1/3] pstore: Delete six error messages for a failed memory allocation SF Markus Elfring
2017-08-16 19:32 ` Kees Cook
2017-08-16 19:58 ` SF Markus Elfring
2017-08-16 19:22 ` SF Markus Elfring [this message]
2017-08-16 19:33 ` [PATCH 2/3] pstore: Improve a size determination in three functions Kees Cook
2017-08-16 20:03 ` SF Markus Elfring
2017-08-16 19:23 ` [PATCH 3/3] pstore: Adjust two checks for null pointers SF Markus Elfring
2017-08-16 19:32 ` Kees Cook
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=23798ef4-5559-3454-ecf4-e6844b644ff3@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=anton@enomsg.org \
--cc=ccross@android.com \
--cc=keescook@chromium.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
/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