staging: comedi: pcmuio: fix possible NULL deref on detach
authorIan Abbott <abbotti@mev.co.uk>
Tue, 20 Aug 2013 10:50:19 +0000 (11:50 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Dec 2013 15:45:11 +0000 (07:45 -0800)
commitbc049656c27b34c9b1f5f36ffa95f7a73b82c8a4
tree4d23d72881eba231d629b2bce6dd5bf5bf373c42
parent5232a7194556c819b2cea0b8395895dc5a448aae
staging: comedi: pcmuio: fix possible NULL deref on detach

commit 2fd2bdfccae61efe18f6b92b6a45fbf936d75b48 upstream.

pcmuio_detach() is called by the comedi core even if pcmuio_attach()
returned an error, so `dev->private` might be `NULL`.  Check for that
before dereferencing it.

Also, as pointed out by Dan Carpenter, there is no need to check the
pointer passed to `kfree()` is non-NULL, so remove that check.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/pcmuio.c