Skip to content

Commit

Permalink
USB: serial: digi_acceleport: Eliminate a NULL pointer dereference
Browse files Browse the repository at this point in the history
If port is NULL, then the call to dev_err will dereference a value that is
a small offset from NULL.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@r exists@
expression E,E1;
identifier f;
statement S1,S2,S3;
@@

if ((E == NULL && ...) || ...)
{
  ... when != if (...) S1 else S2
      when != E = E1
* E->f
  ... when any
  return ...;
}
else S3
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Julia Lawall authored and Greg Kroah-Hartman committed Jun 4, 2010
1 parent 1f23b2d commit 109f34e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/usb/serial/digi_acceleport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,7 @@ static void digi_write_bulk_callback(struct urb *urb)

/* port and serial sanity check */
if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
dev_err(&port->dev,
"%s: port or port->private is NULL, status=%d\n",
pr_err("%s: port or port->private is NULL, status=%d\n",
__func__, status);
return;
}
Expand Down

0 comments on commit 109f34e

Please sign in to comment.