From: Dan Carpenter <dan.carpenter@oracle.com>
To: David Airlie <airlied@linux.ie>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] agp: Use kcalloc() as a hardening measure
Date: Mon, 28 Feb 2022 10:45:13 +0300 [thread overview]
Message-ID: <20220228074513.GB13685@kili> (raw)
The advantage of the kcalloc() function is that it checks for integer
overflows. We should use it where ever possible as a safety measure.
Plus it is nicer for style reasons as well.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/char/agp/frontend.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index 321118a9cfa5..25b27ca0ab47 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -167,7 +167,7 @@ int agp_create_segment(struct agp_client *client, struct agp_region *region)
struct agp_segment *user_seg;
size_t i;
- seg = kzalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL);
+ seg = kcalloc(region->seg_count, sizeof(struct agp_segment_priv), GFP_KERNEL);
if (seg == NULL) {
kfree(region->seg_list);
region->seg_list = NULL;
--
2.20.1
reply other threads:[~2022-02-28 7:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220228074513.GB13685@kili \
--to=dan.carpenter@oracle.com \
--cc=airlied@linux.ie \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®