From: Jesper Juhl <jesper.juhl@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: linux-fbdev-devel@lists.sourceforge.net,
Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH] add NULL short circuit to fb_dealloc_cmap()
Date: Sun, 17 Jul 2005 20:43:41 +0200 [thread overview]
Message-ID: <200507172043.41473.jesper.juhl@gmail.com> (raw)
Resource freeing functions should generally be safe to call with NULL pointers.
Why?
- there is some precedence in the kernel for this for deallocation functions.
- removes the need for callers to check pointers for NULL.
- space is saved overall by less code to test pointers for NULL all over the place.
- removes possible NULL pointer dereferences when a caller forgot to check.
This patch makes fb_dealloc_cmap() safe to call with a NULL pointer argument.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
drivers/video/fbcmap.c | 3 +++
1 files changed, 3 insertions(+)
--- linux-2.6.13-rc3-orig/drivers/video/fbcmap.c 2005-06-17 21:48:29.000000000 +0200
+++ linux-2.6.13-rc3/drivers/video/fbcmap.c 2005-07-17 20:33:43.000000000 +0200
@@ -130,6 +130,9 @@ fail:
void fb_dealloc_cmap(struct fb_cmap *cmap)
{
+ if (unlikely(!cmap))
+ return;
+
kfree(cmap->red);
kfree(cmap->green);
kfree(cmap->blue);
next reply other threads:[~2005-07-17 18:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-17 18:43 Jesper Juhl [this message]
2005-07-17 20:22 ` [PATCH] add NULL short circuit to fb_dealloc_cmap() Jon Smirl
2005-07-17 21:14 ` Geert Uytterhoeven
2005-07-17 21:35 ` Jan Engelhardt
2005-07-17 22:32 ` Jon Smirl
2005-07-26 7:13 ` Geert Uytterhoeven
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=200507172043.41473.jesper.juhl@gmail.com \
--to=jesper.juhl@gmail.com \
--cc=geert@linux-m68k.org \
--cc=linux-fbdev-devel@lists.sourceforge.net \
--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