mirror of
https://github.com/OpenAMP/open-amp.git
synced 2026-02-05 10:41:57 +08:00
lib: remoteproc: Fix remoteproc_remove_virtio
The code contains redundant checks with both metal_assert(vdev) and if (!vdev). Moreover, if the assert is disabled, it may lead to dereferencing a null pointer. We should not rely on asserts for API validation. Instead, replace the assert with an error message. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
This commit is contained in:
committed by
Arnaud Pouliquen
parent
e8866ee7df
commit
be5770f305
@@ -1036,13 +1036,15 @@ void remoteproc_remove_virtio(struct remoteproc *rproc,
|
||||
struct remoteproc_virtio *rpvdev;
|
||||
|
||||
(void)rproc;
|
||||
metal_assert(vdev);
|
||||
|
||||
if (vdev) {
|
||||
rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
|
||||
metal_list_del(&rpvdev->node);
|
||||
rproc_virtio_remove_vdev(&rpvdev->vdev);
|
||||
if (!vdev) {
|
||||
metal_err("vdev not unregistered as null\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
|
||||
metal_list_del(&rpvdev->node);
|
||||
rproc_virtio_remove_vdev(&rpvdev->vdev);
|
||||
}
|
||||
|
||||
int remoteproc_get_notification(struct remoteproc *rproc, uint32_t notifyid)
|
||||
|
||||
Reference in New Issue
Block a user