From patchwork Thu Mar 23 13:17:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 74087 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2927381wrt; Thu, 23 Mar 2023 07:00:54 -0700 (PDT) X-Google-Smtp-Source: AK7set8bWwqQUTsDr7QWnUVJQMfum99ppvhEiu9lpaZ57ahQG4O3qR0YXgYtjpmS1WLfIzok+VD5 X-Received: by 2002:a05:6a00:1da8:b0:5a8:c913:b108 with SMTP id z40-20020a056a001da800b005a8c913b108mr6082987pfw.9.1679580054437; Thu, 23 Mar 2023 07:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679580054; cv=none; d=google.com; s=arc-20160816; b=trqd8HGaIomUEZgxIO67rJ/6f3JfgfveJeQ4shgN0umFuEO3T8+RcSyrmWbE/EBgN3 3rVj5vXACHrNnKn63GeD5rd68ZeDfXLhOad33D58Cl3yamynny5ll6uTqLzxTrPQe1gE ha186TrhNXTeN2YuWW0K9GOXiQVylEVo1tP55h87J3c7Aa4yrBQQDryA08JCBzz0aGdG Vmj9UPEZy7X1IIzF17ba9vFnoaeHx99a5RS94cMSdT2knqlKS3T4tm/XHzUtZKiwE5Bj KAGNUQDSBYxVFh4mvaXr/vKqiDRJm6eEcANQw1PJajjq7Hq8dXMT2U61Iv9uUPnwB1wP XagA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=fqQCmfhEq4ZfCvQHb4AqvhnL3Z4Wt4vyC3Bv8xrha5o=; b=h+3oK8JZrZUXrsCwcWHW/l3W0FMy1DpBFKgaTnsxzdyoFnoEoyINfmfpcajgF3DrC+ 2m0MVb6rrpA9tMQM6o/ZbqZOWdLAhQjnQOhYC3Xc4Ew2LmxL8FAVXs5//duee6RmSw2L VPiCoHmWeGt+9bpM2eqgcbSG1f1rVS7Wby36uQJH3RnxqyxESbtPfnvvJkUBdbcXdaYA KWeccAcIRFLgdjkWKQdM40tpER81SQulqPQzUEz5Z0YG7aNQE0jnOls2z+yUxaOllhqK w8x+MAw2bMXzEtaMGSkJe8dBtB40Smbmk3r0KkPEc7DC1InYeHlELkLuLGIX/WyvvBnY wJjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Hj1qOVlv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f9-20020a056a001ac900b0062811fe3db2si7340543pfv.190.2023.03.23.07.00.40; Thu, 23 Mar 2023 07:00:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Hj1qOVlv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231635AbjCWNRT (ORCPT + 99 others); Thu, 23 Mar 2023 09:17:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbjCWNRR (ORCPT ); Thu, 23 Mar 2023 09:17:17 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6145B1CAD0; Thu, 23 Mar 2023 06:17:14 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:94d9:3023:d284:f7ca]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id EAB6366003AC; Thu, 23 Mar 2023 13:17:11 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1679577432; bh=k3pBI43jV9sj+/C08t+/IGaYJb3nAScopZL9mcMnChk=; h=From:To:Cc:Subject:Date:From; b=Hj1qOVlvySoUESeEAdmE7f/6bM8aPgWLQJrpQfkoKTfCRpoNYltwB+ZYhhRTRXdiM 6D9MVLliT3DG2k3YENkj/dq5D5a+HlwAhJTKoZ3nfuhDOasfJ4Um6bGaC3Jt/PyhJt EclS2G0S//IyCJopff9PwTbJS8CloW7FK9aQdOxWTD0lEs6OqFJaZQpQq8tRr0Kc6N 4URdFc2wYN43a4zTtZcdo1icqSG9j9BOnhfArMELTdMKrW3ZOtmkFs7nMJLAVdQMxh kP8hK+azdiIOi4ypYqV6qGW6OAf0CkZ04+75o7Fa9ipwYHKWgYXnRcN87ZPCxucLpz zvRDGg2inxh+g== From: Benjamin Gaignard To: ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, mchehab@kernel.org, elfring@users.sourceforge.net Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH] media: verisilicon: Simplify error handling in tile_buffer_reallocate() Date: Thu, 23 Mar 2023 14:17:04 +0100 Message-Id: <20230323131704.414281-1-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761167335165145140?= X-GMAIL-MSGID: =?utf-8?q?1761167335165145140?= Rework allocation errors cases handling to simply it by removing useless tests. Signed-off-by: Benjamin Gaignard Reported-by: Markus Elfring --- .../media/platform/verisilicon/hantro_hevc.c | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_hevc.c b/drivers/media/platform/verisilicon/hantro_hevc.c index 9383fb7081f6..2c14330bc562 100644 --- a/drivers/media/platform/verisilicon/hantro_hevc.c +++ b/drivers/media/platform/verisilicon/hantro_hevc.c @@ -109,7 +109,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx) &hevc_dec->tile_filter.dma, GFP_KERNEL); if (!hevc_dec->tile_filter.cpu) - goto err_free_tile_buffers; + return -ENOMEM; hevc_dec->tile_filter.size = size; size = (VERT_SAO_RAM_SIZE * height64 * (num_tile_cols - 1) * ctx->bit_depth) / 8; @@ -125,31 +125,26 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx) &hevc_dec->tile_bsd.dma, GFP_KERNEL); if (!hevc_dec->tile_bsd.cpu) - goto err_free_tile_buffers; + goto err_free_sao_buffers; hevc_dec->tile_bsd.size = size; hevc_dec->num_tile_cols_allocated = num_tile_cols; return 0; -err_free_tile_buffers: - if (hevc_dec->tile_filter.cpu) - dma_free_coherent(vpu->dev, hevc_dec->tile_filter.size, - hevc_dec->tile_filter.cpu, - hevc_dec->tile_filter.dma); - hevc_dec->tile_filter.cpu = NULL; - +err_free_sao_buffers: if (hevc_dec->tile_sao.cpu) dma_free_coherent(vpu->dev, hevc_dec->tile_sao.size, hevc_dec->tile_sao.cpu, hevc_dec->tile_sao.dma); hevc_dec->tile_sao.cpu = NULL; - if (hevc_dec->tile_bsd.cpu) - dma_free_coherent(vpu->dev, hevc_dec->tile_bsd.size, - hevc_dec->tile_bsd.cpu, - hevc_dec->tile_bsd.dma); - hevc_dec->tile_bsd.cpu = NULL; +err_free_tile_buffers: + if (hevc_dec->tile_filter.cpu) + dma_free_coherent(vpu->dev, hevc_dec->tile_filter.size, + hevc_dec->tile_filter.cpu, + hevc_dec->tile_filter.dma); + hevc_dec->tile_filter.cpu = NULL; return -ENOMEM; }