Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2570224rdb; Mon, 4 Dec 2023 00:52:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3Q+qyu3VASHKZ14WRA2k2UQF+//CFYiyXrSjCVHYL4AVyiTPgTUNxhFgZ6soqDY4lU2Tq X-Received: by 2002:a05:6a20:6a08:b0:18c:8d21:7346 with SMTP id p8-20020a056a206a0800b0018c8d217346mr1871216pzk.28.1701679974492; Mon, 04 Dec 2023 00:52:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701679974; cv=none; d=google.com; s=arc-20160816; b=V8ZRKFJZbk4mcq+3V2ZKbkXPo9sfem97AoVqTMveDFquYPHql2d+8jSIP06+P09k61 5re5FLSyFkDRB75PHrsXhQKthB+RBjbEPSxZgw7MkkGSVP0+XAFSFsi4Q0bGZei1PR2M 4c79qZOcX3DEAiij31UUtUWSeNpRzsOw2AaF1jeuYqgLUzQEEBorHzb0ucaY0KQ2TJYg oy9zhfDP+CXRh3/hqbracjt92x3sVqm/Wr/0SuRU2t+8TEeYFT3H3lPWLJpc/3/EpI5p 4S8jBhWhvobyjXxAHddFmuO/lYipjHSbSCP2NHHUIJfGt7xkklvtxBSuilLGvFhDN9+4 KONA== 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; bh=EyhYVCbfPyOd//jhYHaIALu25esL2y2sxv9pEaF/cfI=; fh=eBhRUjn2AaVNHeGVenOk+fLSPaT/JS7Ukv037e8ED/c=; b=1Is/D+N5CqQ6HOKhBfhjSJXct6/vvyjW8KqmTx5YoR5dnkpKgoaWnHaQWyV0Dy2pl7 qn3MtwnFKOH5Yj2LmpNlPqIUsXZ5CduPzOGR3z34WVOy4umSQcxvOsiUWFb1dMueAfLT LgXBrRdFLZktqtVUesGpdivyu3FBUgiyH0T0N7gZ44Z/92DbNV7ntpL2OhbmicGxpwAE r/GPhFpnx0fui3z50neTK8XA5OYoF2wobyd7WzkJJ1VA6wx347miZqLNgZ8KDiONubMO YrGYh3TKRR5Llp6yNgH3yFm2CWMJ7FO5ZEXY0xgwObyhGyMXz7rHXB8cKA9PDjIZgjlT r1dQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s3-20020a170902a50300b001cfce833b63si7235399plq.83.2023.12.04.00.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 00:52:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A410F809D3E1; Mon, 4 Dec 2023 00:52:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbjLDIwl (ORCPT + 99 others); Mon, 4 Dec 2023 03:52:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231174AbjLDIlB (ORCPT ); Mon, 4 Dec 2023 03:41:01 -0500 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED7F985; Mon, 4 Dec 2023 00:41:04 -0800 (PST) X-UUID: 94c43d4646274f73b49aa72bda893c9e-20231204 X-CID-UNFAMILIAR: 1 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:dcb7f021-d129-4af6-8d07-a3f5b0d30702,IP:5,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:8,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:13 X-CID-INFO: VERSION:1.1.33,REQID:dcb7f021-d129-4af6-8d07-a3f5b0d30702,IP:5,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:8,FILE:0,BULK:0,RULE:Release_HamU,ACTION:r elease,TS:13 X-CID-META: VersionHash:364b77b,CLOUDID:6b04ca60-c89d-4129-91cb-8ebfae4653fc,B ulkID:231204164052U6WTZBVA,BulkQuantity:0,Recheck:0,SF:66|38|24|16|19|44|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_USA,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 94c43d4646274f73b49aa72bda893c9e-20231204 X-User: zengchi@kylinos.cn Received: from localhost.localdomain [(116.128.244.169)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 1513602924; Mon, 04 Dec 2023 16:40:50 +0800 From: Zeng Chi To: nas.chung@chipsnmedia.com, jackson.lee@chipsnmedia.com, mchehab@kernel.org, sebastian.fricke@collabora.com, nicolas.dufresne@collabora.com, hverkuil-cisco@xs4all.nl, bob.beckett@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, zengchi@kylinos.cn Subject: [PATCH] Fix memory leaks in wave5_vpu_open_enc() and wave5_vpu_open_dec() Date: Mon, 4 Dec 2023 16:39:57 +0800 Message-Id: <20231204083957.2835095-1-zengchi@kylinos.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 00:52:53 -0800 (PST) This patch fixes memory leaks on error escapes in wave5_vpu_open_enc() and wave5_vpu_open_dec(). 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 | 4 +++- drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 4 +++- 2 files changed, 6 insertions(+), 2 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..2d3e8a184f93 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c @@ -1792,8 +1792,10 @@ static int wave5_vpu_open_dec(struct file *filp) int ret = 0; inst = kzalloc(sizeof(*inst), GFP_KERNEL); - if (!inst) + if (!inst) { + kfree(inst); return -ENOMEM; + } inst->dev = dev; inst->type = VPU_INST_TYPE_DEC; 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..cbf6cb6e07aa 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c @@ -1537,8 +1537,10 @@ static int wave5_vpu_open_enc(struct file *filp) int ret = 0; inst = kzalloc(sizeof(*inst), GFP_KERNEL); - if (!inst) + if (!inst) { + kfree(inst); return -ENOMEM; + } v4l2_ctrl_hdl = &inst->v4l2_ctrl_hdl; inst->dev = dev; -- 2.25.1