lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 17 Dec 2008 14:22:41 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Evgeniy Polyakov <zbr@...emap.net>
Cc:	linux-kernel@...r.kernel.org, zbr@...emap.net
Subject: Re: [w1] Allow master IO commands.

On Tue, 16 Dec 2008 21:07:59 +0300
Evgeniy Polyakov <zbr@...emap.net> wrote:

> This patch allows to start IO not against already found slave devices,
> but against the bus itself, which can be used for example to probe device.
> 
> ...
>
> +static int w1_process_command_master(struct w1_master *dev, struct cn_msg *req_msg,
> +		struct w1_netlink_msg *req_hdr, struct w1_netlink_cmd *req_cmd)
> +{
> +	int err = -EINVAL;
> +	struct cn_msg *msg;
> +	struct w1_netlink_msg *hdr;
> +	struct w1_netlink_cmd *cmd;
> +
> +	msg = kzalloc(PAGE_SIZE, GFP_KERNEL);

The use of PAGE_SIZE is odd.  It's either too large (inefficient) or
too small (disaster).

Is it not practical to calculate this precisely?

> +	if (!msg)
> +		return -ENOMEM;
> +
> +	msg->id = req_msg->id;
> +	msg->seq = req_msg->seq;
> +	msg->ack = 0;
> +	msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd);
> +
> +	hdr = (struct w1_netlink_msg *)(msg + 1);
> +	cmd = (struct w1_netlink_cmd *)(hdr + 1);
> +
> +	hdr->type = W1_MASTER_CMD;
> +	hdr->id = req_hdr->id;
> +	hdr->len = sizeof(struct w1_netlink_cmd);
> +
> +	cmd->cmd = req_cmd->cmd;
> +	cmd->len = 0;
> +
> +	switch (cmd->cmd) {
> +		case W1_CMD_SEARCH:

checkpatch correctly points out that the body of the switch statement
should be indented one tabstop less than this.

> +		case W1_CMD_ALARM_SEARCH:
> +			err = w1_process_search_command(dev, msg,
> +				PAGE_SIZE - msg->len - sizeof(struct cn_msg));

which would give more room for cleaning this up.

> +			break;
> +		case W1_CMD_READ:
> +		case W1_CMD_WRITE:
> +		case W1_CMD_TOUCH:
> +			err = w1_process_command_io(dev, msg, hdr, cmd);
> +			break;
> +		default:
> +			cmd->res = EINVAL;
> +			cn_netlink_send(msg, 0, GFP_KERNEL);
> +			break;
> +	}
> +
> +	kfree(msg);
> +	return err;
> +}
> +

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ