drivers: modem: receiver: guards against 0 size
Protects against 0 size in send, receive, and registration. Signed-off-by: Georgij Cernysiov <g.cernysiov@elco-automation.de>
This commit is contained in:
parent
27618404f6
commit
3fe917ef64
|
@ -166,8 +166,12 @@ int mdm_receiver_recv(struct mdm_receiver_context *ctx,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
*bytes_read = ring_buf_get(&ctx->rx_rb, buf, size);
|
||||
if (size == 0) {
|
||||
*bytes_read = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*bytes_read = ring_buf_get(&ctx->rx_rb, buf, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -178,6 +182,10 @@ int mdm_receiver_send(struct mdm_receiver_context *ctx,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
do {
|
||||
uart_poll_out(ctx->uart_dev, *buf++);
|
||||
} while (size--);
|
||||
|
@ -191,7 +199,7 @@ int mdm_receiver_register(struct mdm_receiver_context *ctx,
|
|||
{
|
||||
int ret;
|
||||
|
||||
if (!ctx) {
|
||||
if ((!ctx) || (size == 0)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue