misc: fastrpc: Unmap only if buffer is unmapped from DSP
[platform/kernel/linux-starfive.git] / drivers / misc / fastrpc.c
index 3cdc584..1c6c62a 100644 (file)
@@ -1981,11 +1981,13 @@ static int fastrpc_req_mem_unmap_impl(struct fastrpc_user *fl, struct fastrpc_me
        sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MEM_UNMAP, 1, 0);
        err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc,
                                      &args[0]);
-       fastrpc_map_put(map);
-       if (err)
+       if (err) {
                dev_err(dev, "unmmap\tpt fd = %d, 0x%09llx error\n",  map->fd, map->raddr);
+               return err;
+       }
+       fastrpc_map_put(map);
 
-       return err;
+       return 0;
 }
 
 static int fastrpc_req_mem_unmap(struct fastrpc_user *fl, char __user *argp)