Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3087672rdh; Mon, 27 Nov 2023 06:19:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPGlnnxIdDm9z44XBdkEERKRbwTcdDqP7u492ZJ39ThAjrEByLy/E3ymigm+BHq8vm++8J X-Received: by 2002:a05:6a00:1483:b0:6cb:82bb:5238 with SMTP id v3-20020a056a00148300b006cb82bb5238mr11580763pfu.30.1701094774185; Mon, 27 Nov 2023 06:19:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701094774; cv=none; d=google.com; s=arc-20160816; b=O3oabvUHpFD5YXpNKnQ+enpJbi3/27pQyJYvQrj0M4S1fncektE61r4XTIv/ctTDs1 8q7xh7z8vo0+auu/kjn7ndu2R+yL8EQ/JfY+pXSZz8kfFzWGDbmhD+jRb0OkNMa+gc+6 D/AugG4ZeqQb3bsB3RcmLrmNY1VqwgDcAsgz9wlNQ2U4eLo4ODk3gQ/UTcsJjQRWYS/K KTtbZonf/g0ZDZxaSLgkHplTpYtFhC2BvdTzSvg35D0iJo8MD8k2lDz5PUXKkUfxX6d3 Ky+FPfCsRStu1GDgCAmmad23iG9FkgX+KIxbYI27Vo3akvjY/PeD1USELkrGJmQd0As7 OEBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6p7Yk0pPh+5XOIFlXKbXoyDeljmm58+0nwJPnMfZeAs=; fh=eRbLiCXD08L2H9avuVrep2oaSCiQ5oG2hjCaE1mDlyI=; b=WoiOglmMxSXMeAtICFaLxfXtOMDwUw3bGFNHm5VU/IsDjY9WG2/VdCIMvyy+vUV/lC gKmQZC8UIwkZLCeAKWxNs5LNCGjV8iAu2qfRohBt1NZPbTjwmyhhngEsyeYhdHdTDS5y GuDMH+OGIYsW6AWHVABy9+MnDdnKEWlom0nnFx+UVXu6Iy636jHpkBZ7ESoArD0n9xzK V1Xh6FkU7Hy8HypJxsBVso/L0kN8oB0yqtlrOduBFgUVR9VGsQoci/IgxfL/P3WV8BuA mU9mBZWov4nlUtMV1FPUahAxz58MCixNDrkofFfx/swwQ+Mg7vuisml5jmsWd9WyY/Vj WlVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=CL8f33vz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id k16-20020a056a00135000b006cbd40b46basi9775318pfu.133.2023.11.27.06.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:19:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=CL8f33vz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id C520380965A3; Mon, 27 Nov 2023 06:19:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233614AbjK0OTC (ORCPT + 99 others); Mon, 27 Nov 2023 09:19:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233541AbjK0OSo (ORCPT ); Mon, 27 Nov 2023 09:18:44 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C79543AA0 for ; Mon, 27 Nov 2023 06:16:11 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40859dee28cso34863775e9.0 for ; Mon, 27 Nov 2023 06:16:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701094570; x=1701699370; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6p7Yk0pPh+5XOIFlXKbXoyDeljmm58+0nwJPnMfZeAs=; b=CL8f33vzDfInh8DW9OeVyj7o/Me0n3OXqUPjMexwnhcJA9cpCLL+jlHglkqAyQ2RQE 2ajYM98zQbGfQ5AVXGcIkigh6ayM5DGkBUc7dcKzcZ2/U6Lrj29i1bz7wJkVPozNTlGf Lk5k3+Bwg4SJ/a70Te9y5pEpgkgKAdoXbnhTVcFBArPju2RAGMi/jUwaDJmoTqOTTu1w 5rvamGporhW1VT/vC8soJvLshja9Uejwk+FIHN7nyZNdykIG+WypDgxvl4Yc9PergTBN I36eaJOTglNcLtgXARRmC3Bw00I7SiIpyrtzqu3oSadPQX+SxLIYlXv8pNcCJQd/TVEz ZWcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701094570; x=1701699370; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6p7Yk0pPh+5XOIFlXKbXoyDeljmm58+0nwJPnMfZeAs=; b=eaShsKJiqXPNVDTtULqFlW4HOuFdfzUrCb+tKlRX+Q0FWrPkNQbWJulvpO2qDwqmVW 3wiMWdeWoc6pjmCE9PEKUY21KkUNqHYaKsWB8u6W/qqikj2tDyKFew1kpdpD1vweQ7X2 gumeViTwizXZPW4LcDif3Sl786dJVKod9Kxw+jYNEQxsFX+7s4jTQvwD1f5CH/oPXcBc pi+52LLp85oO2GwUT9v3R9Ymlyw1ISDq7hYAeOhLqvNaK+Cs9aXbTp/gongZKVNDCWWP qnhnNk98QkBdpWdvvBL1vlvelCuRIYT00mNgaUf8iOmA2uLmodWgGxumaCtrHuXQyzwA b3mw== X-Gm-Message-State: AOJu0YzZpmDm+CwT4SqRRaE8dQ1+pUh4C/gWKfpWEuBekHfoSq5cYnFo P2DWC58ojKjXZVE10Dk8Dp9uvg== X-Received: by 2002:a05:600c:684:b0:408:56ea:f061 with SMTP id a4-20020a05600c068400b0040856eaf061mr9276619wmn.24.1701094570027; Mon, 27 Nov 2023 06:16:10 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:bf33:77c7:8131:5e64]) by smtp.gmail.com with ESMTPSA id be7-20020a05600c1e8700b00405442edc69sm14658830wmb.14.2023.11.27.06.16.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:16:09 -0800 (PST) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Elliot Berman , Krzysztof Kozlowski , Guru Das Srinagesh , Andrew Halaney , Maximilian Luz , Alex Elder , Srini Kandagatla Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Bartosz Golaszewski , kernel test robot , Dan Carpenter Subject: [PATCH v6 01/13] firmware: qcom: qseecom: fix memory leaks in error paths Date: Mon, 27 Nov 2023 15:15:48 +0100 Message-Id: <20231127141600.20929-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231127141600.20929-1-brgl@bgdev.pl> References: <20231127141600.20929-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 27 Nov 2023 06:19:23 -0800 (PST) From: Bartosz Golaszewski Fix instances of returning error codes directly instead of jumping to the relevant labels where memory allocated for the SCM calls would be freed. Fixes: 759e7a2b62eb ("firmware: Add support for Qualcomm UEFI Secure Application") Reported-by: kernel test robot Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202311270828.k4HGcjiL-lkp@intel.com/ Signed-off-by: Bartosz Golaszewski --- .../firmware/qcom/qcom_qseecom_uefisecapp.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c b/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c index a33acdaf7b78..32188f098ef3 100644 --- a/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c +++ b/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c @@ -325,8 +325,10 @@ static efi_status_t qsee_uefi_get_variable(struct qcuefi_client *qcuefi, const e req_data->length = req_size; status = ucs2_strscpy(((void *)req_data) + req_data->name_offset, name, name_length); - if (status < 0) - return EFI_INVALID_PARAMETER; + if (status < 0) { + efi_status = EFI_INVALID_PARAMETER; + goto out_free; + } memcpy(((void *)req_data) + req_data->guid_offset, guid, req_data->guid_size); @@ -471,8 +473,10 @@ static efi_status_t qsee_uefi_set_variable(struct qcuefi_client *qcuefi, const e req_data->length = req_size; status = ucs2_strscpy(((void *)req_data) + req_data->name_offset, name, name_length); - if (status < 0) - return EFI_INVALID_PARAMETER; + if (status < 0) { + efi_status = EFI_INVALID_PARAMETER; + goto out_free; + } memcpy(((void *)req_data) + req_data->guid_offset, guid, req_data->guid_size); @@ -563,8 +567,10 @@ static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi, memcpy(((void *)req_data) + req_data->guid_offset, guid, req_data->guid_size); status = ucs2_strscpy(((void *)req_data) + req_data->name_offset, name, *name_size / sizeof(*name)); - if (status < 0) - return EFI_INVALID_PARAMETER; + if (status < 0) { + efi_status = EFI_INVALID_PARAMETER; + goto out_free; + } status = qcom_qseecom_app_send(qcuefi->client, req_data, req_size, rsp_data, rsp_size); if (status) { @@ -635,7 +641,7 @@ static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi, * have already been validated above, causing this function to * bail with EFI_BUFFER_TOO_SMALL. */ - return EFI_DEVICE_ERROR; + efi_status = EFI_DEVICE_ERROR; } out_free: -- 2.40.1