bus/fslmc: fix dereferencing null pointer
authorApeksha Gupta <apeksha.gupta@nxp.com>
Fri, 8 May 2020 13:02:02 +0000 (18:32 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 11 May 2020 20:27:39 +0000 (22:27 +0200)
Fixes: 6fef517e17cf ("bus/fslmc: add qman HW fq query count API")
Cc: stable@dpdk.org
Signed-off-by: Apeksha Gupta <apeksha.gupta@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
drivers/bus/fslmc/qbman/qbman_debug.c

index 0bb2ce8..4cd0923 100644 (file)
@@ -27,19 +27,20 @@ int qbman_fq_query_state(struct qbman_swp *s, uint32_t fqid,
                         struct qbman_fq_query_np_rslt *r)
 {
        struct qbman_fq_query_desc *p;
+       struct qbman_fq_query_np_rslt *var;
 
        p = (struct qbman_fq_query_desc *)qbman_swp_mc_start(s);
        if (!p)
                return -EBUSY;
 
        p->fqid = fqid;
-       *r = *(struct qbman_fq_query_np_rslt *)qbman_swp_mc_complete(s, p,
-                                               QBMAN_FQ_QUERY_NP);
-       if (!r) {
+       var = qbman_swp_mc_complete(s, p, QBMAN_FQ_QUERY_NP);
+       if (!var) {
                pr_err("qbman: Query FQID %d NP fields failed, no response\n",
                       fqid);
                return -EIO;
        }
+       *r = *var;
 
        /* Decode the outcome */
        QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_FQ_QUERY_NP);