Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4061482rdh; Tue, 28 Nov 2023 10:41:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHoCAinsN9gk/iJOAqfKgxyMU2fsYVPXgNG0rfDzrV27Se0aY1iWUEOurCWfWg+F1ZsVcL3 X-Received: by 2002:a05:620a:34f:b0:77d:c863:b991 with SMTP id t15-20020a05620a034f00b0077dc863b991mr1076845qkm.20.1701196883265; Tue, 28 Nov 2023 10:41:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701196883; cv=none; d=google.com; s=arc-20160816; b=su03+H9r7uiq+g42HV9O9s1VQt+0DJiyLjhflDQ8+lmAnYEhSYehSpR3eaMXKMyj77 /HZ3uTYoYK73smW+uqMbLSr9Qp6PPMmFWZ1l+hbiHS4QC1r1vm/ktdLsqIjHvrv1sdHP 6UgJVXdthJy0T43YQgZLRaulgxYoBp8maaobfRtAsQOKaUSp26vlp8jbNyJPByNP7AZR lpeXc5ZuWjdPLrCdTqXn+KUX8EF0ESiFJYkgERVx3h9k7b98ULIJb08Cn7jUzPz0T0Mp cfyANrgOn2inbMffqsG7FnxPPtxA+Zb8Uv6CLXL6mt0OkC8uCweh6acQ9T1Mo0dFXsCA xleA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:organization:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=Xim2S9cQW+e5njis2ljcosM2qz8PJh2IGhPtrK7TjuM=; fh=wUTlGmLlKLp93MUKnr3d3QKj/gU8FBkm5VlR5/sMquE=; b=mwKueFPj8LWlkdGB3DaknAVTLpf36xaRuC2Arh1ljeV6+HqV4C9HWMmkN2OabuhlMA 9ac6WkxVFL4Wxdvzxr24iSlBe46dTzPlHLI70azQ61x6UJKefAUG+OxxfIvt6bbYKUbN cE09TVXVXLWPW4ze1gaQHU43VWmYs9FW1k7X3+PCL77FGnig5JwOYu4mt8t4yBw85cLE mebAQD8H6XatR8+CsS+wBi/7zTj0ZH5DJfBHKLbOuJe46YoPbvHfFilXGi+GgsodMiQ7 +1SUI8zQ33jV9ZAniCHJXUQeglwzL7DrMK9PCXI65Li3VgoGQUK9WpSkukPjLbBImFcc yGLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZMn+ZwjG; spf=pass (google.com: domain of linux-crypto+bounces-363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-363-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c10-20020a05620a0cea00b0077d5ea857e9si11092345qkj.715.2023.11.28.10.41.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 10:41:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZMn+ZwjG; spf=pass (google.com: domain of linux-crypto+bounces-363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-363-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DF3D31C20983 for ; Tue, 28 Nov 2023 18:41:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B3853D0AF for ; Tue, 28 Nov 2023 18:41:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZMn+ZwjG" X-Original-To: linux-crypto@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F9E7210C for ; Tue, 28 Nov 2023 09:56:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701194186; x=1732730186; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=jANSly3SCs0KMx1UgUvYj11BDQWDzndCBmMmO7qQydo=; b=ZMn+ZwjG/HYIUTKi738nHUsAOZol3rdkRC9FFE1xrvkQIuLmrashb1Ia zlOp9Xi99Gpz+r/k93Ar1vr84uMaCO3wgoVBFC73kBuIDblsUvbncMxsm Bs6HRQtR5eLq+0rbW4FZhiL1x6IDp+FE8URGykJjuxXqdo7kQ/deWBPSP tlTClE6Mibc1im/JvPTAN1lWBZsVVYs2awYGy5HlJ6zZLBHc7pq7caeED H1rC2eSf2LrobpfH5mwOQrASP11o2TnaxXqYpw3I/fYBKfmSbIiwhqQak E0QjE9rqB1L9Opd09iEnWiNMftuIeXZHZ3qQqX4T3U4/nruRwNxHaBtaq g==; X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="383367885" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="383367885" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 09:56:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="886489477" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="886489477" Received: from r031s002_zp31l10c01.deacluster.intel.com (HELO localhost.localdomain) ([10.219.171.29]) by fmsmga002.fm.intel.com with ESMTP; 28 Nov 2023 09:56:24 -0800 From: Damian Muszynski To: herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com, Damian Muszynski , Dan Carpenter , Giovanni Cabiddu Subject: [PATCH] crypto: qat - fix error path in add_update_sla() Date: Tue, 28 Nov 2023 18:37:32 +0100 Message-ID: <20231128173828.84083-1-damian.muszynski@intel.com> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 Content-Transfer-Encoding: 8bit The input argument `sla_in` is a pointer to a structure that contains the parameters of the SLA which is being added or updated. If this pointer is NULL, the function should return an error as the data required for the algorithm is not available. By mistake, the logic jumps to the error path which dereferences the pointer. This results in a warnings reported by the static analyzer Smatch when executed without a database: drivers/crypto/intel/qat/qat_common/adf_rl.c:871 add_update_sla() error: we previously assumed 'sla_in' could be null (see line 812) This issue was not found in internal testing as the pointer cannot be NULL. The function add_update_sla() is only called (indirectly) by the rate limiting sysfs interface implementation in adf_sysfs_rl.c which ensures that the data structure is allocated and valid. This is also proven by the fact that Smatch executed with a database does not report such error. Fix it by returning with error if the pointer `sla_in` is NULL. Fixes: d9fb8408376e ("crypto: qat - add rate limiting feature to qat_4xxx") Reported-by: Dan Carpenter Signed-off-by: Damian Muszynski Reviewed-by: Giovanni Cabiddu --- drivers/crypto/intel/qat/qat_common/adf_rl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/crypto/intel/qat/qat_common/adf_rl.c b/drivers/crypto/intel/qat/qat_common/adf_rl.c index 86e3e2152b1b..f2de3cd7d05d 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_rl.c +++ b/drivers/crypto/intel/qat/qat_common/adf_rl.c @@ -812,8 +812,7 @@ static int add_update_sla(struct adf_accel_dev *accel_dev, if (!sla_in) { dev_warn(&GET_DEV(accel_dev), "SLA input data pointer is missing\n"); - ret = -EFAULT; - goto ret_err; + return -EFAULT; } /* Input validation */ base-commit: 27265511a765f4380257319b0c088097b9cf1a71 -- 2.41.0