Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3213209rdb; Sat, 9 Dec 2023 17:18:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJtJZl2aokXdFZG/dSQ8bDVtaExHhrNvDtVPHxVnryYANo5m8liu9swKDdWe6ZHY8nYBcb X-Received: by 2002:a05:6a20:3d93:b0:18c:8ff1:f16 with SMTP id s19-20020a056a203d9300b0018c8ff10f16mr3315564pzi.1.1702171136223; Sat, 09 Dec 2023 17:18:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702171136; cv=none; d=google.com; s=arc-20160816; b=bYbOx0JxHdTumcYsvHEg7nhEhokOyIpUmarNxVjCyJ3nD5VFcu5OivCvVoEDmCAwCG PHdzztu/m4OcpvpScqt+v8tBbCjPz3IadrOlUxKZm3Pzf8vDOE54XWrJ90tTNie5N0+a 8lcLf81o0irvpKagycs2VUzWFd5mQmbGWvkwBphRHvUqspI1+5NpG8nbXpDpjnAgqFDZ kNT5T7IMat8yHJ2yLt+kGkH2wgEh4pdAjnHIjvIPeiiJ1W35CEW+eOx6p37e6oDp5eYb jChHxzHksAH0SyuV51UkOoW+SszUuUcGjg3+7br5tpGCYpIT4sez69iT7GVz5BkU3Grh QKIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=OSqJ3Gq1m5O067Yev9/OhXEqr6xxNOyvhwu0WzwCQqM=; fh=H6M4i7hjcXsIgh+3G9CWSdsBL37o5uvR5ZhV1EKryUk=; b=ekK1kd+dfsbg3OCThDPcXey4cb7e5e45kB3Lf5XLHawjSbgF1MEmjQKYHQAhKbncSt LH+eGq+m1iPzW3sKo+VCX6404388r4b+gLYDPzjNK08nnbbHw831B0rIfXVgpRcaZGs1 uAcNOWD+FxibzphY1fDmNA2OGF4sE2PMbhJkwJuWVoD47o/UH1hGUOUbykIkN4LknQu9 nrr2wLbKL+kvW7mgPSgzJTHIw6EKUtkkwl+bx0/00RVNvQidM4fJnA/QMDeEss2zzkOQ 2F0CreNwmM8/ZdTn4GHCUtdqQBv5xyEavwUaViNOJjPn+HzXN07G72bioGEq0seWeMcv N1Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OdBxe7yl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id w6-20020a056a0014c600b006cb6338dd60si3868068pfu.19.2023.12.09.17.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 17:18:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OdBxe7yl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 28E068061563; Sat, 9 Dec 2023 17:18:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229556AbjLJBSd (ORCPT + 99 others); Sat, 9 Dec 2023 20:18:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbjLJBSb (ORCPT ); Sat, 9 Dec 2023 20:18:31 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADD86D0; Sat, 9 Dec 2023 17:18:37 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3332e351670so3169978f8f.0; Sat, 09 Dec 2023 17:18:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702171116; x=1702775916; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=OSqJ3Gq1m5O067Yev9/OhXEqr6xxNOyvhwu0WzwCQqM=; b=OdBxe7ylAJGaQPnQB2Y92RuHLAXnc+aAeYX4FOmIHvOrNyG8PNVnGqV8R7yNVZQtfB uolsb+OQpFJ+BeJk3SCBXSuqvqZ7hpIS6bAKiBfs6Pc8p2cCJ2IluGioYchsIBsVkm5V WA+AhaQXjXUQMxNc0GpJKPvLpQ/YfU/O9AGQ59Zjt80Fqjm1gTr9ClonQR56rXrnyJrU bgUFEgSXaz3pG5fkeFR4l4l3UHma71zrhpG3eQlHOmu63BR851//bJMddgRsty8klcf5 /6fneuE3vBAzYPjhdL6z5OOFFFEaNcbh70FgURPS5t0WpYeWhChJng+7ioy1YVHekv2O ELNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702171116; x=1702775916; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OSqJ3Gq1m5O067Yev9/OhXEqr6xxNOyvhwu0WzwCQqM=; b=lot2+BMaZ0Y7zfkM3j0lc300tg4IY7JcmIUoxyon0UeBolJzIv/8BJrM8cW3zPXjq3 eJRFI9unOA+FQTsWzvebBtbX5mjJOFeb5en2Mq/qVIgg5kr3K+tIFhE+b7YaHqU0io3h R3Hnl3VB03AxtnPO4YRhsiimkK53svk7azeR8u08k7dYhGums6zAM9yIYkSfBff7DhkQ XJVPCaXUi2PpqnM2cUVISE+NVbJwLfbLerdG6/YIBdF1Q9wn1e1SSPpLOGtAsnWTHV2Q HSE2ORby1xotD049LF4hIAaIDIcqrVQgp+kPGPAi/VRubfvrfR3Mc6wbI11gQRqfkWGj boMw== X-Gm-Message-State: AOJu0YyU2zvLxbJfQRKSA7Ji41EOP54uG8MtJbiKew3u1DFTg5nT9ZAl NSwjrJSIxMrJk3/JhZVxiJYykn5DoRM= X-Received: by 2002:adf:f882:0:b0:333:3117:c453 with SMTP id u2-20020adff882000000b003333117c453mr666048wrp.228.1702171115790; Sat, 09 Dec 2023 17:18:35 -0800 (PST) Received: from ?IPV6:2a02:8071:b783:140:927c:82ba:d32d:99c1? ([2a02:8071:b783:140:927c:82ba:d32d:99c1]) by smtp.gmail.com with ESMTPSA id a9-20020a5d5709000000b003332aa97101sm5322013wrv.38.2023.12.09.17.18.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 Dec 2023 17:18:35 -0800 (PST) Message-ID: Date: Sun, 10 Dec 2023 02:18:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 01/13] firmware: qcom: qseecom: fix memory leaks in error paths Content-Language: en-US To: Bartosz Golaszewski , Andy Gross , Bjorn Andersson , Konrad Dybcio , Elliot Berman , Krzysztof Kozlowski , Guru Das Srinagesh , Andrew Halaney , 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 References: <20231127141600.20929-1-brgl@bgdev.pl> <20231127141600.20929-2-brgl@bgdev.pl> From: Maximilian Luz In-Reply-To: <20231127141600.20929-2-brgl@bgdev.pl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 agentk.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 (agentk.vger.email [0.0.0.0]); Sat, 09 Dec 2023 17:18:53 -0800 (PST) On 11/27/23 15:15, Bartosz Golaszewski wrote: > 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 Thanks! Reviewed-by: Maximilian Luz > --- > .../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: