From: Marc Kleine-Budde <mkl@pengutronix.de>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-can@vger.kernel.org,
Alexey Khoroshilov <khoroshilov@ispras.ru>,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 1/2] can: softing: Fix potential memory leak in softing_load_fw()
Date: Fri, 24 Aug 2012 11:30:42 +0200 [thread overview]
Message-ID: <1345800643-29456-2-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1345800643-29456-1-git-send-email-mkl@pengutronix.de>
From: Alexey Khoroshilov <khoroshilov@ispras.ru>
Do not leak memory by updating pointer with potentially NULL realloc return value.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/softing/softing_fw.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/softing/softing_fw.c b/drivers/net/can/softing/softing_fw.c
index 3105961..b595d34 100644
--- a/drivers/net/can/softing/softing_fw.c
+++ b/drivers/net/can/softing/softing_fw.c
@@ -150,7 +150,7 @@ int softing_load_fw(const char *file, struct softing *card,
const uint8_t *mem, *end, *dat;
uint16_t type, len;
uint32_t addr;
- uint8_t *buf = NULL;
+ uint8_t *buf = NULL, *new_buf;
int buflen = 0;
int8_t type_end = 0;
@@ -199,11 +199,12 @@ int softing_load_fw(const char *file, struct softing *card,
if (len > buflen) {
/* align buflen */
buflen = (len + (1024-1)) & ~(1024-1);
- buf = krealloc(buf, buflen, GFP_KERNEL);
- if (!buf) {
+ new_buf = krealloc(buf, buflen, GFP_KERNEL);
+ if (!new_buf) {
ret = -ENOMEM;
goto failed;
}
+ buf = new_buf;
}
/* verify record data */
memcpy_fromio(buf, &dpram[addr + offset], len);
--
1.7.10
next prev parent reply other threads:[~2012-08-24 9:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-24 9:30 pull-request: can 2012-08-24 Marc Kleine-Budde
2012-08-24 9:30 ` Marc Kleine-Budde [this message]
2012-08-24 9:30 ` [PATCH 2/2] can: sja1000_platform: fix wrong flag IRQF_SHARED for interrupt sharing Marc Kleine-Budde
2012-08-24 19:21 ` pull-request: can 2012-08-24 David Miller
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=1345800643-29456-2-git-send-email-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=davem@davemloft.net \
--cc=khoroshilov@ispras.ru \
--cc=linux-can@vger.kernel.org \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).