Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[IRDA] irda_device_dongle_init: fix kzalloc(GFP_KERNEL) in spinlock

Fix http://bugzilla.kernel.org/show_bug.cgi?id=8343

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Samuel Ortiz <samuel@sortiz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Andrew Morton and committed by
David S. Miller
1c8ea5ae 14690fc6

+8 -13
+8 -13
net/irda/irda_device.c
··· 375 375 dongle_t *irda_device_dongle_init(struct net_device *dev, int type) 376 376 { 377 377 struct dongle_reg *reg; 378 - dongle_t *dongle = NULL; 378 + dongle_t *dongle = kzalloc(sizeof(dongle_t), GFP_KERNEL); 379 379 380 380 might_sleep(); 381 381 ··· 397 397 if (!reg || !try_module_get(reg->owner) ) { 398 398 IRDA_ERROR("IrDA: Unable to find requested dongle type %x\n", 399 399 type); 400 - goto out; 400 + kfree(dongle); 401 + dongle = NULL; 401 402 } 402 - 403 - /* Allocate dongle info for this instance */ 404 - dongle = kzalloc(sizeof(dongle_t), GFP_KERNEL); 405 - if (!dongle) 406 - goto out; 407 - 408 - /* Bind the registration info to this particular instance */ 409 - dongle->issue = reg; 410 - dongle->dev = dev; 411 - 412 - out: 403 + if (dongle) { 404 + /* Bind the registration info to this particular instance */ 405 + dongle->issue = reg; 406 + dongle->dev = dev; 407 + } 413 408 spin_unlock(&dongles->hb_spinlock); 414 409 return dongle; 415 410 }