* [bug report] cxgb4/ch_ktls: Clear resources when pf4 device is removed
@ 2021-05-15 10:42 Dan Carpenter
2021-05-17 10:18 ` Ayush Sawal
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-05-15 10:42 UTC (permalink / raw)
To: ayush.sawal; +Cc: kernel-janitors
Hello Ayush Sawal,
This is a semi-automatic email about new static checker warnings.
The patch 65e302a9bd57: "cxgb4/ch_ktls: Clear resources when pf4
device is removed" from May 13, 2021, leads to the following Smatch
complaint:
drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c:393 chcr_ktls_dev_del()
error: we previously assumed 'u_ctx' could be null (see line 374)
drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
373 u_ctx = tx_info->adap->uld[CXGB4_ULD_KTLS].handle;
374 if (u_ctx && u_ctx->detach)
^^^^^
Can u_ctx be NULL?
375 return;
376 /* clear l2t entry */
377 if (tx_info->l2te)
378 cxgb4_l2t_release(tx_info->l2te);
379
380 #if IS_ENABLED(CONFIG_IPV6)
381 /* clear clip entry */
382 if (tx_info->ip_family == AF_INET6)
383 cxgb4_clip_release(netdev, (const u32 *)
384 &tx_info->sk->sk_v6_rcv_saddr,
385 1);
386 #endif
387
388 /* clear tid */
389 if (tx_info->tid != -1) {
390 cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan,
391 tx_info->tid, tx_info->ip_family);
392
393 xa_erase(&u_ctx->tid_list, tx_info->tid);
^^^^^^^^^^^^^^^^
Unchecked dereference.
394 }
395
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [bug report] cxgb4/ch_ktls: Clear resources when pf4 device is removed
2021-05-15 10:42 [bug report] cxgb4/ch_ktls: Clear resources when pf4 device is removed Dan Carpenter
@ 2021-05-17 10:18 ` Ayush Sawal
0 siblings, 0 replies; 2+ messages in thread
From: Ayush Sawal @ 2021-05-17 10:18 UTC (permalink / raw)
To: Dan Carpenter; +Cc: ayush.sawal, kernel-janitors, Rohit Maheshwari
Hi Dan,
Thanks for pointing this out.
The u_ctx pointer in case of ch_ktls will always be valid.
So this condition if(u_ctx && u_ctx->detach) must be if(u_ctx->detach).
and xa_erase(&u_ctx->tid_list, tx_info->tid) doesnot requires a u_ctx check.
So I will send a fix which replaces if(u_ctx && u_ctx->detach) to
if(u_ctx->detach)
and removes the checks for u_ctx pointer in ch_ktls driver.
Thanks,
Ayush
On 5/15/2021 4:12 PM, Dan Carpenter wrote:
> Hello Ayush Sawal,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 65e302a9bd57: "cxgb4/ch_ktls: Clear resources when pf4
> device is removed" from May 13, 2021, leads to the following Smatch
> complaint:
>
> drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c:393 chcr_ktls_dev_del()
> error: we previously assumed 'u_ctx' could be null (see line 374)
>
> drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
> 373 u_ctx = tx_info->adap->uld[CXGB4_ULD_KTLS].handle;
> 374 if (u_ctx && u_ctx->detach)
> ^^^^^
> Can u_ctx be NULL?
>
> 375 return;
> 376 /* clear l2t entry */
> 377 if (tx_info->l2te)
> 378 cxgb4_l2t_release(tx_info->l2te);
> 379
> 380 #if IS_ENABLED(CONFIG_IPV6)
> 381 /* clear clip entry */
> 382 if (tx_info->ip_family == AF_INET6)
> 383 cxgb4_clip_release(netdev, (const u32 *)
> 384 &tx_info->sk->sk_v6_rcv_saddr,
> 385 1);
> 386 #endif
> 387
> 388 /* clear tid */
> 389 if (tx_info->tid != -1) {
> 390 cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan,
> 391 tx_info->tid, tx_info->ip_family);
> 392
> 393 xa_erase(&u_ctx->tid_list, tx_info->tid);
> ^^^^^^^^^^^^^^^^
> Unchecked dereference.
>
> 394 }
> 395
>
> regards,
> dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-17 9:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-15 10:42 [bug report] cxgb4/ch_ktls: Clear resources when pf4 device is removed Dan Carpenter
2021-05-17 10:18 ` Ayush Sawal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox