Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp447906rdb; Tue, 5 Dec 2023 09:37:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRHJ4251vRlVwXjVfqig8ET+Wccw2mJ5UO/oRZuXJQUg/vVYqXvb5LVTd5Hqz1L30cSTkj X-Received: by 2002:a05:6a00:180c:b0:6cb:8a8a:4bb6 with SMTP id y12-20020a056a00180c00b006cb8a8a4bb6mr2290487pfa.11.1701797831751; Tue, 05 Dec 2023 09:37:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701797831; cv=none; d=google.com; s=arc-20160816; b=BdHf4Ngh0xmtOuzWWOSUVziMeTXUFtkR397ObpUVeIl4G2MxdMcPeWkqoaK8/EUkQR jkzvg4L+P80I17wj1k0+9q7/Ov9PXVpm7zA4riN679u7vQ1WvLeSMP6Rnf1nIifCZN+G ypvLTPvSfeZ+/mK0w8FJYrgYOGcvSqLsMjURyeecNyW+mN4mB1zuG7eRa8QG4CYhoSew rxn4+aHzpK9ws0B8MkzYg2RXvp8Y4mCFDjGBVMSy6ddLQUByIO0I3jUbmEdqDtHCa8Wv P54D5vVNLiKSjsoE3tHrKTIRq2QrF0EvqhYkUYl1HRIvyfDiMmNstJ6zc2jf+Nejgzhz o+Gw== 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 :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=wpe5pweZebrtVVomcxwwdAUZAdjQXCn2wIaFyahTmTk=; fh=9izkISXFcOMlWIQNcJTCGcYVPvm74v+7Bj/54d3KrOA=; b=0LrmYH6WP3s3ShG+YNpicxpabQDqKiHURi9p9eqxgI8gextcoPzASWZ/ixONKIHK+/ Z0Vw0W6gEgp9IxrImWCqLsJgCsWsuDtL2BRziTDSFD1vQRRX4BLxQlrS7rFdrvlLuAOj 4o0Lcuffux2lDXm7yhOx8FMoorFYo/hMYW/PC4EwimwGS1TqL9MqOcun0aPiF4adK+ic 3Mgy3o8ubIsb4VHrm7g7H7cn5JhlKr9FzwtTvzeqUKNjBYK1B0kpHQEaoaWZUqPIZrEM 3dE78lZTYwkTU6JWTAAObP7wxTElLGwhsdWmHHjE72Ig+C5bxcJP2c5TMX8S+8dzPyhJ odzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TCv6P8tj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id fj8-20020a056a003a0800b0069014d63f21si10069289pfb.148.2023.12.05.09.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 09:37:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TCv6P8tj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id ED5E580968B8; Tue, 5 Dec 2023 09:37:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346204AbjLERgv (ORCPT + 99 others); Tue, 5 Dec 2023 12:36:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346120AbjLERgu (ORCPT ); Tue, 5 Dec 2023 12:36:50 -0500 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 5560FCA; Tue, 5 Dec 2023 09:36:56 -0800 (PST) Received: from [100.90.159.192] (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbeckett) by madras.collabora.co.uk (Postfix) with ESMTPSA id B760866072A7; Tue, 5 Dec 2023 17:36:54 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1701797815; bh=D+BnC18dTewKG1sYUbVzU1UQZRYC0I7GsxPXzOUgVz8=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From; b=TCv6P8tjumaojN4l2jHlx/wDgUI1veQ5m1geiEqrwI4i4bUW39XwQAS9QWbVskzbK krpHBbvW5oiKHqYfWR1cVGzaUhRYKi4pZRx5wVMZZESyhBH5TV29i+y6D+ek7+9lJz pu78E++D7lfHnN6Tvd8TZI3nCpq/c/SXqNbBZ0mkxext2dvJOQpuTj+nUzWD1yMws5 /YWD69LRDL2dnrAgZVvfAom89rc1Q/KfYRTiqJao4ewbvV4ARkfKMDId304oHf3rVV aDWTlrKUUytKiuZ0TsODB4bzHBGmehCJ+HpvVMRjMdyzhOOsiZFn+sv+izgXmWN+ao o4JZyqQowy+3A== Message-ID: Date: Tue, 5 Dec 2023 17:36:43 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Robert Beckett Subject: Re: [PATCH] Fix memory leaks in wave5_vpu_open_enc() and wave5_vpu_open_dec() To: Nicolas Dufresne , Zeng Chi , nas.chung@chipsnmedia.com, jackson.lee@chipsnmedia.com, mchehab@kernel.org, sebastian.fricke@collabora.com, hverkuil-cisco@xs4all.nl Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20231204091649.3418987-1-zengchi@kylinos.cn> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 05 Dec 2023 09:37:09 -0800 (PST) On 04/12/2023 13:55, Nicolas Dufresne wrote: > Hi, > > Le lundi 04 décembre 2023 à 17:16 +0800, Zeng Chi a écrit : >> This patch fixes memory leaks on error escapes in wave5_vpu_open_enc() >> and wave5_vpu_open_dec(). > Please avoid sending twice the same patch. This is still a NAK. tbf, this is a different patch, concerning the allocation of the codec_info within inst, not inst itself. > regards, > Nicolas > >> Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer") >> Signed-off-by: Zeng Chi >> --- >> drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c | 5 +++-- >> drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 5 +++-- >> 2 files changed, 6 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c >> index 8b1417ece96e..b0a045346bb7 100644 >> --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c >> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c >> @@ -1802,9 +1802,10 @@ static int wave5_vpu_open_dec(struct file *filp) >> spin_lock_init(&inst->state_spinlock); >> >> inst->codec_info = kzalloc(sizeof(*inst->codec_info), GFP_KERNEL); >> - if (!inst->codec_info) >> + if (!inst->codec_info) { >> + kfree(inst); for consistency, would be better to jump to cleanup_inst. Also, maybe consider embedding codec_info  in to struct vpu_instance to avoid the double alloc. I've not checked whether this is viable throughout the code, but from a quick scan of the original patch, it looks like it is always allocated and freed alongside inst. >> return -ENOMEM; >> - >> + } >> v4l2_fh_init(&inst->v4l2_fh, vdev); >> filp->private_data = &inst->v4l2_fh; >> v4l2_fh_add(&inst->v4l2_fh); >> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c >> index f29cfa3af94a..bc94de9ea546 100644 >> --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c >> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c >> @@ -1546,9 +1546,10 @@ static int wave5_vpu_open_enc(struct file *filp) >> inst->ops = &wave5_vpu_enc_inst_ops; >> >> inst->codec_info = kzalloc(sizeof(*inst->codec_info), GFP_KERNEL); >> - if (!inst->codec_info) >> + if (!inst->codec_info) { >> + kfree(inst); >> return -ENOMEM; >> - >> + } >> v4l2_fh_init(&inst->v4l2_fh, vdev); >> filp->private_data = &inst->v4l2_fh; >> v4l2_fh_add(&inst->v4l2_fh);