In eal_intr_proc_rxtx_intr, negative value may be used as argument to
a function expecting a positive value. If 'read' returns EAGAIN as
example, the bytes_read updates to a negative value which continue
be passed as argument for the next 'read'.
Coverity issue: 107115
Function read(fd, &buf, bytes_read) returns a negative number.
Assigning: signed variable bytes_read = read.
CID 107115 (#1 of 1): Argument cannot be negative
(NEGATIVE_RETURNS) bytes_read is passed to a parameter
that cannot be negative.
bytes_read = read(fd, &buf, bytes_read);
Fixes:
c9f3ec1a0f3f ("eal/linux: add Rx interrupt control function")
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
{
union rte_intr_read_buffer buf;
int bytes_read = 1;
{
union rte_intr_read_buffer buf;
int bytes_read = 1;
switch (intr_handle->type) {
case RTE_INTR_HANDLE_UIO:
switch (intr_handle->type) {
case RTE_INTR_HANDLE_UIO:
* for epoll_wait.
*/
do {
* for epoll_wait.
*/
do {
- bytes_read = read(fd, &buf, bytes_read);
- if (bytes_read < 0) {
+ nbytes = read(fd, &buf, bytes_read);
+ if (nbytes < 0) {
if (errno == EINTR || errno == EWOULDBLOCK ||
errno == EAGAIN)
continue;
RTE_LOG(ERR, EAL,
"Error reading from fd %d: %s\n",
fd, strerror(errno));
if (errno == EINTR || errno == EWOULDBLOCK ||
errno == EAGAIN)
continue;
RTE_LOG(ERR, EAL,
"Error reading from fd %d: %s\n",
fd, strerror(errno));
- } else if (bytes_read == 0)
+ } else if (nbytes == 0)
RTE_LOG(ERR, EAL, "Read nothing from fd %d\n", fd);
return;
} while (1);
RTE_LOG(ERR, EAL, "Read nothing from fd %d\n", fd);
return;
} while (1);