Re: [PATCH 3/8] staging/mei: MEI "Link" layer code - MEI Hardwarecommunications.

From: Greg KH
Date: Wed Apr 27 2011 - 11:18:08 EST


On Wed, Apr 27, 2011 at 01:27:32PM +0300, Oren Weil wrote:
> +/**
> + * mei_flow_ctrl_creds - checks flow_control credentials.
> + *
> + * @dev: the device structure
> + * @file_ext: private data of the file object
> + *
> + * returns 1 if mei_flow_ctrl_creds >0, 0 - otherwise.
> + */
> +int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *file_ext)
> +{
> + int i;
> +
> + if (!dev->num_mei_me_clients)
> + return 0;
> +
> + if (file_ext == NULL)
> + return 0;
> +
> + if (file_ext->mei_flow_ctrl_creds > 0)
> + return 1;
> +
> + for (i = 0; i < dev->num_mei_me_clients; i++) {
> + if (dev->me_clients[i].client_id == file_ext->me_client_id) {
> + if (dev->me_clients[i].mei_flow_ctrl_creds > 0) {
> + BUG_ON(dev->me_clients[i].props.single_recv_buf
> + == 0);
> + return 1;
> + }
> + return 0;
> + }
> + }
> + BUG();
> + return 0;

What?

You just crashed your device with no chance of recovery. NEVER put a
BUG() or BUG_ON() call in a driver, that is just rude in irresponsible.

Especially with a return 0; after it, that's just trying to outsmart the
compiler warning, which is extra foolish.

This happens in other places in this code as well, please fix.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/