2011/6/23 Michal Nazarewicz <mina86@xxxxxxxxxx>: > On Thu, 23 Jun 2011 13:13:58 +0200, Amit Nagal <helloin.amit@xxxxxxxxx> > wrote: >> >> while going through skel_release() code in usb-skeleton driver , i >> noticed the following statements : >> >> static int skel_release(struct inode *inode, struct file *file) >> { >> struct usb_skel *dev; >> >> dev = file->private_data; >> >> if (dev == NULL) >> return -ENODEV; >> >> ....... >> } >> >> but i am trying to understand the scenario where ( dev == NULL ) can >> come true and skel_release() returns -ENODEV . >> >> since in skel_open() , file->private_data saves dev with ( >> file->private_data = dev ) statement , > > Not always. There are two “goto exit” statements that will skip setting > of the file->private_data. > Ya , but "goto exit" are there to handle error conditions , which will finally lead to failure of open() call in userspace . since open() fails , application wont get valid fd for calling close() , and thus skel_release won't execute at all . Regards Amit Nagal -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html