[rds-devel] [bug report] net/rds: fix WARNING in rds_conn_connect_if_down

Dan Carpenter dan.carpenter at linaro.org
Fri Mar 15 15:21:17 UTC 2024


Hello Edward Adam Davis,

Commit c055fc00c07b ("net/rds: fix WARNING in
rds_conn_connect_if_down") from Mar 5, 2024 (linux-next), leads to
the following Smatch static checker warning:

	net/rds/rdma.c:306 __rds_rdma_map()
	error: we previously assumed 'cp' could be null (see line 291)

net/rds/rdma.c
    284                 rdsdebug("RDS: trans_private nents is %u\n", nents);
    285         }
    286         /* Obtain a transport specific MR. If this succeeds, the
    287          * s/g list is now owned by the MR.
    288          * Note that dma_map() implies that pending writes are
    289          * flushed to RAM, so no dma_sync is needed here. */
    290         trans_private = rs->rs_transport->get_mr(
    291                 sg, nents, rs, &mr->r_key, cp ? cp->cp_conn : NULL,
                                                   ^^
Check for NULL

    292                 args->vec.addr, args->vec.bytes,
    293                 need_odp ? ODP_ZEROBASED : ODP_NOT_NEEDED);
    294 
    295         if (IS_ERR(trans_private)) {
    296                 /* In ODP case, we don't GUP pages, so don't need
    297                  * to release anything.
    298                  */
    299                 if (!need_odp) {
    300                         unpin_user_pages(pages, nr_pages);
    301                         kfree(sg);
    302                 }
    303                 ret = PTR_ERR(trans_private);
    304                 /* Trigger connection so that its ready for the next retry */
    305                 if (ret == -ENODEV)
--> 306                         rds_conn_connect_if_down(cp->cp_conn);
                                                         ^^^^
Unchecked dereference

    307                 goto out;
    308         }
    309 
    310         mr->r_trans_private = trans_private;

regards,
dan carpenter



More information about the rds-devel mailing list