Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp623769pxb; Tue, 5 Apr 2022 16:18:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxN6M8m7X3RlS/xRQAK3I2tVeUOlsCb/Vkz0gmmLBr883JJ58LRvpfah33UnqE53Q//jF+z X-Received: by 2002:a17:902:d488:b0:156:b0c7:218a with SMTP id c8-20020a170902d48800b00156b0c7218amr5928357plg.2.1649200739268; Tue, 05 Apr 2022 16:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649200739; cv=none; d=google.com; s=arc-20160816; b=LLldoedq4Kpx+77resJdDkEmpd8PsG//FW/WbToucL5DTFcNU9QAvsitXRlmi7CPQC vIIAY4S+VB193b0UysDqi5D+jcnFDiADcjTFf2X15LGPvqBKHH4LBOpSlmQhxNgl3vO3 GIe13YivcQM1go9sJJTKgbPBwCBJxlZ7m2FPL73H/Avf2fS7U43LVTfzIznZa8sMcTnw oshucua1yde/zDLmdlGVI2VUBZLmC1yh84Ve5b+nyEnvyXeytbWyl7CjEtZM3H/x2j/L TWkHiHd9C2DPgwqDGvXq3rbBxdlHZses1p33eya+Gi6L84zLAPTa4Wh7mIZmT0FsBG3I TfLQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J0Wk2tQxTgRK5zeHIHJKvYmntQLWO7she0IUSAf7x4E=; b=CQDwmeucQWAcOj3rPGyexUUtMDRq3KV8P16OLUi+Q1n9Gifh+/jBrfABliM8Kju/19 JO6O0Gu7FgqSCtzrVc8KqaWUObhN+U9FdMaxxNyM3VAinakdadokmn2Vd/eMRvhSfW+M g23kJ9BkQ+Re5jT6sNX6QVHjleH6jSgrLh9vmrgcdwjSHoU05IvI/hbIo4ESvpKQiEPn wZOI9+E5Sa7oqQfeu965dDmW2fCT1u/9FVgksN0afZ7wLc8O8Mx8q0tB+JFy+7t6ODpc xOF7TCWYeRk9HNWhlnk/R8yde/3pQwIRbAI9u6GeX0Ki5JaTyo12niarF5HlTE5mn6Np mbUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U1IaPhFM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l3-20020a170902f68300b00153b2d1649dsi15547354plg.165.2022.04.05.16.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:18:59 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U1IaPhFM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8CE0122B6ED; Tue, 5 Apr 2022 16:03:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377844AbiDELar (ORCPT + 99 others); Tue, 5 Apr 2022 07:30:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243962AbiDEIvW (ORCPT ); Tue, 5 Apr 2022 04:51:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EA68CD338; Tue, 5 Apr 2022 01:39:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8C8ACB81B92; Tue, 5 Apr 2022 08:38:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1699C385A3; Tue, 5 Apr 2022 08:38:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649147933; bh=9hCBRRhKdCVoieEBBCzN/gKOJEsz/ukjx7l7GEHMlns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U1IaPhFMeKwpL2UNrazrU4k+gD64YrIfdYbcSVSzDxH4dNH9LN+fT53lPIDkyxDFY 8KRzLRkvzWlylPt77hIjUzmtqk1H8iiSGLd759Lih+dQHpE0RmmDW6Zg5wS8+q4ruQ 7d364HTCORM/n7/d5ei3ujjSFMGE00z8TUvVledQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ameer Hamza , Kieran Bingham , Stanimir Varbanov , Mauro Carvalho Chehab Subject: [PATCH 5.16 0174/1017] media: venus: vdec: fixed possible memory leak issue Date: Tue, 5 Apr 2022 09:18:07 +0200 Message-Id: <20220405070359.394359234@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Ameer Hamza commit 8403fdd775858a7bf04868d43daea0acbe49ddfc upstream. The venus_helper_alloc_dpb_bufs() implementation allows an early return on an error path when checking the id from ida_alloc_min() which would not release the earlier buffer allocation. Move the direct kfree() from the error checking of dma_alloc_attrs() to the common fail path to ensure that allocations are released on all error paths in this function. Addresses-Coverity: 1494120 ("Resource leak") cc: stable@vger.kernel.org # 5.16+ Fixes: 40d87aafee29 ("media: venus: vdec: decoded picture buffer handling during reconfig sequence") Signed-off-by: Ameer Hamza Reviewed-by: Kieran Bingham Signed-off-by: Stanimir Varbanov Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/qcom/venus/helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -189,7 +189,6 @@ int venus_helper_alloc_dpb_bufs(struct v buf->va = dma_alloc_attrs(dev, buf->size, &buf->da, GFP_KERNEL, buf->attrs); if (!buf->va) { - kfree(buf); ret = -ENOMEM; goto fail; } @@ -209,6 +208,7 @@ int venus_helper_alloc_dpb_bufs(struct v return 0; fail: + kfree(buf); venus_helper_free_dpb_bufs(inst); return ret; }