From: Duncan Sands <baldrick@free.fr>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] firmware_class: avoid double free
Date: Sat, 2 Oct 2004 18:51:40 +0200 [thread overview]
Message-ID: <200410021851.40249.baldrick@free.fr> (raw)
The error exit path in request_firmware frees the allocated
struct firmware *firmware, which is good. What is not so good
is that the value of firmware has already been copied out to the
caller as *firmware_p. The risk is that the caller will pass this
to release_firmware, a double free. This is exactly what will
happen if the caller copied the example code
if(request_firmware(&fw_entry, $FIRMWARE, device) == 0)
copy_fw_to_device(fw_entry->data, fw_entry->size);
release(fw_entry);
from the firmware documentation.
--- mm/drivers/base/firmware_class.c.orig 2004-10-02 18:43:00.323005656 +0200
+++ mm/drivers/base/firmware_class.c 2004-10-02 18:43:37.500448654 +0200
@@ -441,6 +441,7 @@
error_kfree_fw:
kfree(firmware);
+ *firmware_p = NULL;
out:
return retval;
}
reply other threads:[~2004-10-02 16:51 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=200410021851.40249.baldrick@free.fr \
--to=baldrick@free.fr \
--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®