Re: [PATCH 2/4] barebox remote control

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

 



>>>>> "Sascha" == Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> writes:

Hi,

 > This adds the ability to control barebox over serial lines. The regular
 > console is designed for human input and is unsuitable for controlling
 > barebox from scripts since characters can be lost on both ends, the data
 > stream contains escape sequences and the prompt cannot be easily matched
 > upon.
 > This approach is based on the RATP protocol. RATP packages start with a
 > binary 0x01 which does not occur in normal console data. Whenever a
 > 0x01 character is detected in the console barebox goes into RATP mode.
 > The RATP packets contain a simple structure with a command/respone
 > type and data for that type. Currently defined types are:


> +int barebox_ratp(struct console_device *cdev)
 > +{
 > +	void *buf = xmalloc(512);
 > +	int ret;
 > +	size_t len;
 > +	struct ratp_ctx *ctx;
 > +	struct ratp *ratp;
 > +
 > +	ctx = xzalloc(sizeof(*ctx));
 > +	ratp = &ctx->ratp;
 > +
 > +	ratp->send = ratp_send;
 > +	ratp->recv = ratp_recv;
 > +	ctx->cdev = cdev;
 > +
 > +	ret = ratp_establish(ratp, false, 0);
 > +	if (ret < 0)
 > +		return ret;
 > +
 > +	ret = ratp_console_register(ctx);
 > +	if (ret)
 > +		return ret;

You're leaking ctx and buf here (and buf below as well).

 > +
 > +	while (1) {
 > +		ret = ratp_poll(ratp);
 > +		if (ret == -EINTR)
 > +			goto out;
 > +		if (ratp_closed(ratp))
 > +			goto out;
 > +
 > +		len = 512;
 > +		ret = ratp_recv_data(ratp, buf, &len);
 > +		if (ret == -EAGAIN)
 > +			continue;
 > +
 > +		if (ret < 0)
 > +			goto out;
 > +
 > +		ret = ratp_bb_dispatch(ctx, buf, len);
 > +		if (ret)
 > +			break;
 > +	}
 > +out:
 > +
 > +	console_unregister(&ctx->ratp_console);
 > +
 > +	free(ctx);
 > +
 > +	return ret;
 > +}


> +++ b/crypto/Kconfig
 > @@ -2,6 +2,7 @@ config CRC32
 >  	bool
 
 >  config CRC16
 > +	default y

Why?

-- 
Bye, Peter Korsgaard

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux