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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux