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.
and dev is always released either in skel_disconnect (in case no open
) or in release function ( on last close ),
in what scenario dev can go NULL when userspace application calls
close() .
BTW. Also note, even thought this is just a technicality, that
calling close() not always results in calling release.
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +-----<email/xmpp: mnazarewicz@xxxxxxxxxx>-----ooO--(_)--Ooo--
--
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