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: tiny-usb: 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
09472cec 32dbfb4d

+3 -10
+3 -10
drivers/i2c/busses/i2c-tiny-usb.c
··· 213 213 return ret; 214 214 } 215 215 216 - static void i2c_tiny_usb_free(struct i2c_tiny_usb *dev) 217 - { 218 - usb_put_dev(dev->usb_dev); 219 - kfree(dev); 220 - } 221 - 222 216 static int i2c_tiny_usb_probe(struct usb_interface *interface, 223 217 const struct usb_device_id *id) 224 218 { ··· 231 237 if (!dev) 232 238 goto error; 233 239 234 - dev->usb_dev = usb_get_dev(interface_to_usbdev(interface)); 240 + dev->usb_dev = interface_to_usbdev(interface); 235 241 dev->interface = interface; 236 242 237 243 /* save our data pointer in this interface device */ ··· 271 277 return 0; 272 278 273 279 error: 274 - if (dev) 275 - i2c_tiny_usb_free(dev); 280 + kfree(dev); 276 281 277 282 return retval; 278 283 } ··· 282 289 283 290 i2c_del_adapter(&dev->adapter); 284 291 usb_set_intfdata(interface, NULL); 285 - i2c_tiny_usb_free(dev); 292 + kfree(dev); 286 293 287 294 dev_dbg(&interface->dev, "disconnected\n"); 288 295 }