[PATCH 1/8] staging: unisys: add toolaction to sysfs

Greg KH gregkh at linuxfoundation.org
Sat Jul 19 19:56:22 UTC 2014


On Sat, Jul 19, 2014 at 10:26:54AM -0400, Benjamin Romer wrote:
> +ssize_t show_toolaction(struct device *dev, struct device_attribute *attr,
> +		char *buf)
> +{
> +	if (ControlVm_channel) {
> +		U8 toolAction;
> +
> +		visorchannel_read(ControlVm_channel,
> +			offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
> +				   ToolAction), &toolAction, sizeof(U8));
> +		return scnprintf(buf, PAGE_SIZE, "%u\n", toolAction);
> +	} else
> +		return -ENODEV;
> +}
> +
> +ssize_t store_toolaction(struct device *dev, struct device_attribute *attr,
> +		const char *buf, size_t count)
> +{
> +	if (ControlVm_channel) {
> +		U8 toolAction;
> +
> +		if (sscanf(buf, "%hhu\n", &toolAction) == 1) {
> +			if (visorchannel_write(ControlVm_channel,
> +				offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
> +					ToolAction),
> +				&toolAction, sizeof(U8)) < 0)
> +					return -EFAULT;
> +				else
> +					return count;
> +		} else
> +			return -EIO;
> +	} else
> +		return -ENODEV;
> +}

How could ControlVm_channel ever be NULL?  Don't check for this, as the
file shouldn't even be here if ControlVm_channel is null.

Same goes for the other sysfs files in this patch series.

thanks,

greg k-h


More information about the devel mailing list