Skip to content

Commit 035eb37

Browse files
committed
i3c: rtio: deal with rtio_cqe_consume() returning NULL
rtio_cqe_consume() may return NULL so we need to check before using any members of the returned struct. Fixes #90473 Fixes #90489 Fixes #90497 Signed-off-by: Daniel Leung <[email protected]>
1 parent 8a0530c commit 035eb37

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

drivers/i3c/i3c_rtio.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* SPDX-License-Identifier: Apache-2.0
66
*/
77

8+
#include <zephyr/toolchain.h>
89
#include <zephyr/drivers/i3c.h>
910
#include <zephyr/drivers/i3c/rtio.h>
1011
#include <zephyr/rtio/rtio.h>
@@ -182,7 +183,11 @@ int i3c_rtio_configure(struct i3c_rtio *ctx, enum i3c_config_type type, void *co
182183
rtio_submit(r, 1);
183184

184185
cqe = rtio_cqe_consume(r);
185-
res = cqe->result;
186+
if (unlikely(cqe != NULL)) {
187+
res = cqe->result;
188+
} else {
189+
res = -EIO;
190+
}
186191
rtio_cqe_release(r, cqe);
187192

188193
out:
@@ -214,7 +219,11 @@ int i3c_rtio_ccc(struct i3c_rtio *ctx, struct i3c_ccc_payload *payload)
214219
rtio_submit(r, 1);
215220

216221
cqe = rtio_cqe_consume(r);
217-
res = cqe->result;
222+
if (unlikely(cqe != NULL)) {
223+
res = cqe->result;
224+
} else {
225+
res = -EIO;
226+
}
218227
rtio_cqe_release(r, cqe);
219228

220229
out:
@@ -245,7 +254,11 @@ int i3c_rtio_recover(struct i3c_rtio *ctx)
245254
rtio_submit(r, 1);
246255

247256
cqe = rtio_cqe_consume(r);
248-
res = cqe->result;
257+
if (unlikely(cqe != NULL)) {
258+
res = cqe->result;
259+
} else {
260+
res = -EIO;
261+
}
249262
rtio_cqe_release(r, cqe);
250263

251264
out:

0 commit comments

Comments
 (0)