public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* re: staging: media: lirc: lirc_zilog.c: replace custom print macros with dev_* and pr_*
@ 2014-10-31 13:06 Dan Carpenter
  2014-10-31 14:26 ` Aya Mahfouz
  0 siblings, 1 reply; 11+ messages in thread
From: Dan Carpenter @ 2014-10-31 13:06 UTC (permalink / raw)
  To: mahfouz.saif.elyazal; +Cc: linux-media, Greg Kroah-Hartman

Hello Aya Mahfouz,

The patch be4aa8157c98: "staging: media: lirc: lirc_zilog.c: replace
custom print macros with dev_* and pr_*" from Oct 26, 2014, leads to
the following static checker warning:

	drivers/staging/media/lirc/lirc_zilog.c:1340 close()
	error: we previously assumed 'ir' could be null (see line 1339)

drivers/staging/media/lirc/lirc_zilog.c
  1333  /* Close the IR device */
  1334  static int close(struct inode *node, struct file *filep)
  1335  {
  1336          /* find our IR struct */
  1337          struct IR *ir = filep->private_data;
  1338  
  1339          if (ir == NULL) {
                    ^^^^^^^^^^
  1340                  dev_err(ir->l.dev, "close: no private_data attached to the file!\n");
                                ^^^^^^^^^

I suggest you just delete the error message.  Can "ir" actually be NULL
here anyway?

  1341                  return -ENODEV;
  1342          }
  1343  

	drivers/staging/media/lirc/lirc_zilog.c:1636 ir_probe()
	error: potential null dereference 'ir'.  (kzalloc returns null)

drivers/staging/media/lirc/lirc_zilog.c
  1614          dev_info(ir->l.dev, "IR unit on %s (i2c-%d) registered as lirc%d and ready\n",
  1615                     adap->name, adap->nr, ir->l.minor);
  1616  
  1617  out_ok:
  1618          if (rx != NULL)
  1619                  put_ir_rx(rx, true);
  1620          if (tx != NULL)
  1621                  put_ir_tx(tx, true);
  1622          put_ir_device(ir, true);
  1623          dev_info(ir->l.dev, "probe of IR %s on %s (i2c-%d) done\n",
  1624                     tx_probe ? "Tx" : "Rx", adap->name, adap->nr);
  1625          mutex_unlock(&ir_devices_lock);
  1626          return 0;
  1627  
  1628  out_put_xx:
  1629          if (rx != NULL)
  1630                  put_ir_rx(rx, true);
                        ^^^^^^^^^^^^^^^^^^^
Btw, I think this is a double free?  On some paths we call put_ir_rx()
before the goto out_put_xx;.

  1631          if (tx != NULL)
  1632                  put_ir_tx(tx, true);
  1633  out_put_ir:
  1634          put_ir_device(ir, true);
  1635  out_no_ir:
  1636          dev_err(ir->l.dev, "%s: probing IR %s on %s (i2c-%d) failed with %d\n",
                        ^^^^^^^^^
Null dereference.

  1637                      __func__, tx_probe ? "Tx" : "Rx", adap->name, adap->nr,
  1638                     ret);
  1639          mutex_unlock(&ir_devices_lock);
  1640          return ret;
  1641  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-11-20 12:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-31 13:06 staging: media: lirc: lirc_zilog.c: replace custom print macros with dev_* and pr_* Dan Carpenter
2014-10-31 14:26 ` Aya Mahfouz
2014-10-31 14:35   ` Dan Carpenter
2014-11-01 20:05     ` Aya Mahfouz
2014-11-06 12:46     ` Sean Young
2014-11-06 13:05       ` Mauro Carvalho Chehab
2014-11-06 13:21         ` Sean Young
     [not found]           ` <697D038C-4BD9-4113-8E7E-B89BACF09AC2@gmail.com>
2014-11-06 13:56             ` Andy Walls
2014-11-09 21:35               ` Sean Young
2014-11-17 14:59                 ` Mauro Carvalho Chehab
2014-11-20 12:38                   ` Sean Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox