Skip to content

Commit

Permalink
[media] Media, DVB, Siano, smsusb: Avoid static analysis report about…
Browse files Browse the repository at this point in the history
… 'use after free'

In drivers/media/dvb/siano/smsusb.c we have this code:
 ...
               kfree(dev);

               sms_info("device %p destroyed", dev);
 ...

at least one static analysis tool (Coverity Prevent) complains about this
as a use-after-free bug.
While it's true that we do use the pointer variable after freeing it, the
only use is to print the value of the pointer, so there's not actually any
problem here. But still, silencing the complaint is trivial by just moving
the kfree() call below the sms_info(), so why not just do it?. It doesn't
change the workings of the code in any way, but it makes the tool shut up.
The patch below also removes a rather pointless blank line.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Jesper Juhl authored and Mauro Carvalho Chehab committed May 20, 2011
1 parent 792bc09 commit 08921ac
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/media/dvb/siano/smsusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,8 @@ static void smsusb_term_device(struct usb_interface *intf)
if (dev->coredev)
smscore_unregister_device(dev->coredev);

kfree(dev);

sms_info("device %p destroyed", dev);
kfree(dev);
}

usb_set_intfdata(intf, NULL);
Expand Down

0 comments on commit 08921ac

Please sign in to comment.