Skip to content

Commit

Permalink
openamp/virtio.h: negotiate also can be call when final_features is NULL
Browse files Browse the repository at this point in the history
add helpful judge for final_features is NULL in virtio_negotiate_features

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
  • Loading branch information
wyr-7 committed Sep 18, 2024
1 parent c468328 commit e09a641
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/include/openamp/virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,15 @@ static inline int virtio_negotiate_features(struct virtio_device *vdev,
uint32_t features,
uint32_t *final_features)
{
if (!vdev || !final_features)
if (!vdev)
return -EINVAL;

if (!vdev->func || !vdev->func->negotiate_features)
return -ENXIO;

*final_features = vdev->func->negotiate_features(vdev, features);
vdev->features = vdev->func->negotiate_features(vdev, features);
if (final_features)
*final_features = vdev->features;
return 0;
}

Expand Down

0 comments on commit e09a641

Please sign in to comment.