Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2719499rdb; Mon, 4 Dec 2023 05:56:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdolmZacPIM/EkM+QgmvEKeTTibqnAZGVwmRBz1/0HZsvOejvRdA0p7mQ+PvBBkGnz/kmr X-Received: by 2002:a05:6358:9188:b0:16e:2762:cdca with SMTP id j8-20020a056358918800b0016e2762cdcamr2050916rwa.3.1701698181232; Mon, 04 Dec 2023 05:56:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701698181; cv=none; d=google.com; s=arc-20160816; b=QxQhbd/4KmoJD+i3CtnNgJTYRpKZr9CzNPjlx3L3Tt00Dq5uWN0KlCYgWVJ6y7QBU6 KaFRNm2eOTPjqTIdsY2ZEJLVNA1sIbnyMp5M0ldmZJYFmviGKbFKfHkV0MW5hoFYmPWk yaaez4LOf06mnvVdOaX7OzVia4egQkZbyS0MZjd6B1XDZQr6+7Z8wCQx+3z9ZrYMWGhW TwKtQFNI/RTJZr/eLjITIEc6HH092FZqALGQc2+LOcbup68b1exkWGaco8E89gFFkqDH h/wIVdEJRC9ZS1bNmZLShuBDe36UJuzVFnxz1VFi5gnbpEWJFoq54TtYLPsDE8dBnUxy IEmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=K/+paZpQm85tNhKV6mHXzwAUyDp8bbrNjz5FS30Z+Pg=; fh=O7lo0Aij/70p/xVuxDpdkniiROz9U8kwmV+Kd/oZY/U=; b=RSjFs9ew5JJSNmkkXU1UdMsi+rIm79R7SZtfHh/9od6vh2H4n5pz4ReQ2MjedMAjqi ARQRk0wEb+IF6q8qdY2CIgnNMVz04PztFUhDHlDqIHm75VAj3UB9tR3iXReSkSoYJdRJ 8EKKBlzOORye0rhFl3pC66exFCPyY3HxmEX9+agT/Xr44xsnUbZVjZPf4SLSQxLSX2fT B21DE1wciuhlOmstWS4X6iRNsKB6AzbvC9WUiUnCsqP5J4sRKDoBS9JBpGbedcjwgi6y ++tQhBFPVmT9a8xRgnxv+iI/YJnHAc76SHLnxSG2XbL6ODQMB3Clu0p954bCZEXU+5u7 9wSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Ih34D7Ow; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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. [23.128.96.38]) by mx.google.com with ESMTPS id h23-20020a635317000000b005b86119661esi7743732pgb.86.2023.12.04.05.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 05:56:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Ih34D7Ow; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 84C7980967AE; Mon, 4 Dec 2023 05:56:18 -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 S235638AbjLDN4B (ORCPT + 99 others); Mon, 4 Dec 2023 08:56:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344854AbjLDNzv (ORCPT ); Mon, 4 Dec 2023 08:55:51 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC7F690; Mon, 4 Dec 2023 05:55:57 -0800 (PST) Received: from nicolas-tpx395.localdomain (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: nicolas) by madras.collabora.co.uk (Postfix) with ESMTPSA id 777066607090; Mon, 4 Dec 2023 13:55:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1701698156; bh=wD2ubbvS7eFYc7JS8cp6iuoHY5//3jKYOuC554SErTw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Ih34D7OwsXYpv77xCCo/dPALgCqYbEPj+mvJ/SdCmiumsp/i5nb9igiwVegqZ0xum 2GdCaNWzog/m9VJ/zN+fJeQWMUz7eJXkgRHxcdDZQvKOgvlnLCHujRQJTco5BRGKma i2gHd0Fws8FMh6FPqJ1yR6LWqQGCzOZwuseF5uQBhiM0RTQCbLAtxx7hx038qFyfXn KF0ip8xvG44l9c2yfimihZXy6oL6p19rDtBNlO5jqIHZZYqrs30yWInqhAFCidRMBM ZKDRpqViPpkzDNOnCuJfJihHclTzCYyt0UhXAsHH57EGtKD57kYc93cp2Nx+w7JzLC kT7/2wOxIWr1g== Message-ID: Subject: Re: [PATCH] Fix memory leaks in wave5_vpu_open_enc() and wave5_vpu_open_dec() From: Nicolas Dufresne To: Zeng Chi , nas.chung@chipsnmedia.com, jackson.lee@chipsnmedia.com, mchehab@kernel.org, sebastian.fricke@collabora.com, hverkuil-cisco@xs4all.nl, bob.beckett@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 04 Dec 2023 08:55:46 -0500 In-Reply-To: <20231204091649.3418987-1-zengchi@kylinos.cn> References: <20231204091649.3418987-1-zengchi@kylinos.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 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]); Mon, 04 Dec 2023 05:56:18 -0800 (PST) Hi, Le lundi 04 d=C3=A9cembre 2023 =C3=A0 17:16 +0800, Zeng Chi a =C3=A9crit=C2= =A0: > 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. regards, Nicolas >=20 > 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(-) >=20 > diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/d= rivers/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); > =20 > inst->codec_info =3D 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 =3D &inst->v4l2_fh; > v4l2_fh_add(&inst->v4l2_fh); > diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c b/d= rivers/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 =3D &wave5_vpu_enc_inst_ops; > =20 > inst->codec_info =3D 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 =3D &inst->v4l2_fh; > v4l2_fh_add(&inst->v4l2_fh);