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

Configure Feed

Select the types of activity you want to include in your feed.

i2c: diolan-u2c: drop redundant device reference

Driver core holds a reference to the USB interface and its parent USB
device while the interface is bound to a driver and there is no need to
take additional references unless the structures are needed after
disconnect.

Drop the redundant device reference to reduce cargo culting, make it
easier to spot drivers where an extra reference is needed, and reduce
the risk of memory leaks when drivers fail to release it.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

authored by

Johan Hovold and committed by
Wolfram Sang
32dbfb4d 7bc4c8f3

+3 -9
+3 -9
drivers/i2c/busses/i2c-diolan-u2c.c
··· 427 427 428 428 MODULE_DEVICE_TABLE(usb, diolan_u2c_table); 429 429 430 - static void diolan_u2c_free(struct i2c_diolan_u2c *dev) 431 - { 432 - usb_put_dev(dev->usb_dev); 433 - kfree(dev); 434 - } 435 - 436 430 static int diolan_u2c_probe(struct usb_interface *interface, 437 431 const struct usb_device_id *id) 438 432 { ··· 447 453 dev->ep_out = hostif->endpoint[0].desc.bEndpointAddress; 448 454 dev->ep_in = hostif->endpoint[1].desc.bEndpointAddress; 449 455 450 - dev->usb_dev = usb_get_dev(interface_to_usbdev(interface)); 456 + dev->usb_dev = interface_to_usbdev(interface); 451 457 dev->interface = interface; 452 458 453 459 /* save our data pointer in this interface device */ ··· 482 488 483 489 error_free: 484 490 usb_set_intfdata(interface, NULL); 485 - diolan_u2c_free(dev); 491 + kfree(dev); 486 492 error: 487 493 return ret; 488 494 } ··· 493 499 494 500 i2c_del_adapter(&dev->adapter); 495 501 usb_set_intfdata(interface, NULL); 496 - diolan_u2c_free(dev); 502 + kfree(dev); 497 503 498 504 dev_dbg(&interface->dev, "disconnected\n"); 499 505 }