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:   Tue, 5 Jul 2022 10:55:50 +0800
From:   Xin Ji <xji@...logixsemi.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        bliang@...logixsemi.com, qwen@...logixsemi.com,
        jli@...logixsemi.com, linux-kernel@...r.kernel.org,
        linux-usb@...r.kernel.org
Subject: Re: [PATCH v12 3/3] usb: typec: anx7411: Add Analogix PD ANX7411
 support

Hi greg k-h, I'll add return value checking.
Thanks,
Xin

On Tue, Jun 28, 2022 at 08:26:07AM +0200, Greg Kroah-Hartman wrote:
> On Tue, Jun 28, 2022 at 12:48:42PM +0800, Xin Ji wrote:
> > +static int anx7411_process_cmd(struct anx7411_data *ctx)
> > +{
> > +	struct device *dev = &ctx->spi_client->dev;
> > +	struct fw_msg *msg = &ctx->recv_msg;
> > +	u8 len;
> > +	u8 crc;
> > +	int ret;
> > +
> > +	/* Read message from firmware */
> > +	ret = anx7411_reg_block_read(ctx->spi_client, CMD_RECV_BUF,
> > +				     MSG_LEN, (u8 *)msg);
> > +	if (ret < 0)
> > +		return 0;
> > +
> > +	if (!msg->msg_len)
> > +		return 0;
> > +
> > +	anx7411_reg_write(ctx->spi_client, CMD_RECV_BUF, 0);
> 
> Again, you are not checking the return value here.  What happens if this
> failed?
> 
> > +
> > +	len = msg->msg_len & MSG_LEN_MASK;
> > +	crc = checksum(dev, (u8 *)msg, len + HEADER_LEN);
> > +	if (crc) {
> > +		dev_err(dev, "message error crc(0x%.02x)\n", crc);
> > +		return -ERANGE;
> > +	}
> > +
> > +	return anx7411_parse_cmd(ctx, msg->msg_type, msg->buf, len - 1);
> > +}
> > +
> > +static void anx7411_translate_payload(struct device *dev, __le32 *payload,
> > +				      u32 *pdo, int nr, const char *type)
> > +{
> > +	int i;
> > +
> > +	if (nr > PDO_MAX_OBJECTS) {
> > +		dev_err(dev, "nr(%d) exceed PDO_MAX_OBJECTS(%d)\n",
> > +			nr, PDO_MAX_OBJECTS);
> > +
> > +		return;
> > +	}
> > +
> > +	for (i = 0; i < nr; i++)
> > +		payload[i] = cpu_to_le32(pdo[i]);
> > +}
> > +
> > +static void anx7411_config(struct anx7411_data *ctx)
> > +{
> > +	struct device *dev = &ctx->spi_client->dev;
> > +	struct typec_params *typecp = &ctx->typec;
> > +	__le32 payload[PDO_MAX_OBJECTS];
> > +
> > +	/* Config PD FW work under PD 2.0 */
> > +	anx7411_reg_write(ctx->spi_client, PD_REV_INIT, PD_REV20);
> > +	anx7411_reg_write(ctx->tcpc_client, FW_CTRL_0,
> > +			  UNSTRUCT_VDM_EN | DELAY_200MS |
> > +			  VSAFE1 | FRS_EN);
> > +	anx7411_reg_write(ctx->spi_client, FW_CTRL_1,
> > +			  AUTO_PD_EN | FORCE_SEND_RDO);
> 
> Same with all of these, what happens if this fails?
> 
> thanks,
> 
> greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ