* [patch] b43: check for allocation failures
@ 2011-06-09 7:09 Dan Carpenter
[not found] ` <BANLkTim3zJNJfGHcaeY+PQN3wm1m20Qzjw@mail.gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2011-06-09 7:09 UTC (permalink / raw)
To: Stefano Brivio
Cc: John W. Linville, open list:B43 WIRELESS DRIVER, kernel-janitors
Add some error handling if the allocation fails.
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/net/wireless/b43/bus.c b/drivers/net/wireless/b43/bus.c
index 6c63aec..8a10b82 100644
--- a/drivers/net/wireless/b43/bus.c
+++ b/drivers/net/wireless/b43/bus.c
@@ -83,7 +83,11 @@ void b43_bus_ssb_block_write(struct b43_bus_dev *dev, const void *buffer,
struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev)
{
- struct b43_bus_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ struct b43_bus_dev *dev;
+
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ if (!dev)
+ return NULL;
dev->bus_type = B43_BUS_SSB;
dev->sdev = sdev;
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index cae3146..c8131a0 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -5025,6 +5025,8 @@ int b43_ssb_probe(struct ssb_device *sdev, const struct ssb_device_id *id)
int first = 0;
dev = b43_bus_dev_ssb_init(sdev);
+ if (!dev)
+ return -ENOMEM;
wl = ssb_get_devtypedata(sdev);
if (!wl) {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch] b43: check for allocation failures
[not found] ` <BANLkTim3zJNJfGHcaeY+PQN3wm1m20Qzjw@mail.gmail.com>
@ 2011-06-09 7:58 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2011-06-09 7:58 UTC (permalink / raw)
To: Rafał Miłecki
Cc: Stefano Brivio, kernel-janitors, open list:B43 WIRELESS DRIVER,
John W. Linville
On Thu, Jun 09, 2011 at 09:43:44AM +0200, Rafał Miłecki wrote:
> > dev = b43_bus_dev_ssb_init(sdev);
> > + if (!dev)
> > + return -ENOMEM;
>
> I'm not sure if you should be aware of the reason here. What about returning
> error code by b43_bus_dev..., reporting it here with b43err and returning
> ENODEV or sth?
The kmalloc failure prints out a whole lot of crap. Surely we don't
need to add more code in every function for an error that is almost
certainly not going to happen in real life.
If we were really worried about returning the right error code, then
we'd return an ERR_PTR() from the lower levels etc. I don't think
it's worth it though.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-09 7:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-09 7:09 [patch] b43: check for allocation failures Dan Carpenter
[not found] ` <BANLkTim3zJNJfGHcaeY+PQN3wm1m20Qzjw@mail.gmail.com>
2011-06-09 7:58 ` Dan Carpenter
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).