From: Prashant Gupta <[email protected]>

Add a null pointer check at the entry of fm_pcd_kg_scheme_delete().
Since p_dev is assigned directly from h_scheme via a cast
(t_device *)h_scheme, checking p_dev == NULL is equivalent to
checking h_scheme == NULL. This matches the defensive pattern used
in all sibling functions in fm_lib.c and returns E_NO_DEVICE on a
null handle.

Fixes: 663ff698e38f ("net/dpaa: support VSP in fmlib")
Cc: [email protected]

Signed-off-by: Prashant Gupta <[email protected]>
---
 drivers/net/dpaa/fmlib/fm_lib.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/dpaa/fmlib/fm_lib.c b/drivers/net/dpaa/fmlib/fm_lib.c
index b35feba004..65a818372e 100644
--- a/drivers/net/dpaa/fmlib/fm_lib.c
+++ b/drivers/net/dpaa/fmlib/fm_lib.c
@@ -305,6 +305,9 @@ fm_pcd_kg_scheme_delete(t_handle h_scheme)
 
        _fml_dbg("Calling...");
 
+       if (p_dev == NULL)
+               return E_NO_DEVICE;
+
        p_pcd_dev =  (t_device *)p_dev->h_user_priv;
        id.obj = UINT_TO_PTR(p_dev->id);
 
-- 
2.43.0

Reply via email to