From patchwork Mon Oct 9 12:27:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cabiddu, Giovanni" X-Patchwork-Id: 13413666 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D81B2E95A91 for ; Mon, 9 Oct 2023 12:27:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346437AbjJIM1f (ORCPT ); Mon, 9 Oct 2023 08:27:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346402AbjJIM1e (ORCPT ); Mon, 9 Oct 2023 08:27:34 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A7888E for ; Mon, 9 Oct 2023 05:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696854452; x=1728390452; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=C1oWo43CK5r4gdmmcsGi90GjGWOFeME/hJfkXElOKys=; b=V139Re5KgKH0qNVuHIR3T/+AvwitgjZUyYwWNVFKF6PVcUNeldm3oZPb RCcRoheEeATl/dvXLqM6whNLGF3hPsFYjwpIIOwqHBPqRXEgCtyFv8Xvb fs8yKeFFrM+rAsNS97A07dTKYdozXfo1RMdR/2eukpB+92xe5SUb2A98b ylJ8uk6F59IB7INHF2ynNO36PLkIXZwdBoLVAYujHbqAEdLMZ1cvI5ptl ja8pU01UCPF0SvlwPfdqoboEnMG020f2Ct6eH7Wz0aRuUMTqlbRQZnJGo 3DT6SPxtmLECrSequq1mGeKJ5EIGUxzFNPmfOCIhL29yISPt4j23XvWNa g==; X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="450628895" X-IronPort-AV: E=Sophos;i="6.03,210,1694761200"; d="scan'208";a="450628895" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 05:27:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="823317447" X-IronPort-AV: E=Sophos;i="6.03,210,1694761200"; d="scan'208";a="823317447" Received: from silpixa00400314.ir.intel.com (HELO silpixa00400314.ger.corp.intel.com) ([10.237.222.216]) by fmsmga004.fm.intel.com with ESMTP; 09 Oct 2023 05:27:29 -0700 From: Giovanni Cabiddu To: herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com, Svyatoslav Pankratov , Giovanni Cabiddu Subject: [PATCH] crypto: qat - fix double free during reset Date: Mon, 9 Oct 2023 13:27:19 +0100 Message-ID: <20231009122723.35136-1-giovanni.cabiddu@intel.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare - Ireland Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Svyatoslav Pankratov There is no need to free the reset_data structure if the recovery is unsuccessful and the reset is synchronous. The function adf_dev_aer_schedule_reset() handles the cleanup properly. Only asynchronous resets require such structure to be freed inside the reset worker. Fixes: d8cba25d2c68 ("crypto: qat - Intel(R) QAT driver framework") Signed-off-by: Svyatoslav Pankratov Signed-off-by: Giovanni Cabiddu --- drivers/crypto/intel/qat/qat_common/adf_aer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/intel/qat/qat_common/adf_aer.c b/drivers/crypto/intel/qat/qat_common/adf_aer.c index 04af32a2811c..a39e70bd4b21 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_aer.c +++ b/drivers/crypto/intel/qat/qat_common/adf_aer.c @@ -92,7 +92,8 @@ static void adf_device_reset_worker(struct work_struct *work) if (adf_dev_restart(accel_dev)) { /* The device hanged and we can't restart it so stop here */ dev_err(&GET_DEV(accel_dev), "Restart device failed\n"); - kfree(reset_data); + if (reset_data->mode == ADF_DEV_RESET_ASYNC) + kfree(reset_data); WARN(1, "QAT: device restart failed. Device is unusable\n"); return; }