From: David Miller <davem@davemloft.net>
To: jj@chaosbits.net
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
netdev@vger.kernel.org, gregkh@suse.de, j.dumon@option.com,
f.aben@option.com, d.barow@option.com, ajb@spheresystems.co.uk
Subject: Re: [PATCH] Net, USB, Option, hso: Do not dereference NULL pointer
Date: Sun, 13 Feb 2011 16:56:08 -0800 (PST) [thread overview]
Message-ID: <20110213.165608.149817059.davem@davemloft.net> (raw)
In-Reply-To: <alpine.LNX.2.00.1102132206390.18930@swampdragon.chaosbits.net>
From: Jesper Juhl <jj@chaosbits.net>
Date: Sun, 13 Feb 2011 22:15:35 +0100 (CET)
> In drivers/net/usb/hso.c::hso_create_bulk_serial_device() we have this
> code:
> ...
> serial = kzalloc(sizeof(*serial), GFP_KERNEL);
> if (!serial)
> goto exit;
> ...
> exit:
> hso_free_tiomget(serial);
> ...
> hso_free_tiomget() directly dereferences its argument, which in the
> example above is a NULL pointer, ouch.
> I could just add a 'if (serial)' test at the 'exit' label, but since most
> freeing functions in the kernel accept NULL pointers (and it seems like
> this was also assumed here) I opted to instead change 'hso_free_tiomget()'
> so that it is safe to call it with a NULL argument. I also modified the
> function to get rid of a pointles conditional before the call to
> 'usb_free_urb()' since that function already tests for NULL itself -
> besides fixing the NULL deref this change also buys us a few bytes in
> size.
> Before:
> $ size drivers/net/usb/hso.o
> text data bss dec hex filename
> 32200 592 9960 42752 a700 drivers/net/usb/hso.o
> After:
> $ size drivers/net/usb/hso.o
> text data bss dec hex filename
> 32196 592 9960 42748 a6fc drivers/net/usb/hso.o
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Applied.
prev parent reply other threads:[~2011-02-14 0:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-13 21:15 [PATCH] Net, USB, Option, hso: Do not dereference NULL pointer Jesper Juhl
2011-02-14 0:56 ` David Miller [this message]
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=20110213.165608.149817059.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=ajb@spheresystems.co.uk \
--cc=d.barow@option.com \
--cc=f.aben@option.com \
--cc=gregkh@suse.de \
--cc=j.dumon@option.com \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.