From patchwork Fri Dec 1 13:22:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhipeng Lu X-Patchwork-Id: 172489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp1114866vqy; Fri, 1 Dec 2023 05:24:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBEGSzm6yZYPe16TDs0mi40FR6graTyKmt0KZikkZtAuf9MEkX16BAD2RiMd24SUNCjnzx X-Received: by 2002:a05:6a20:3d28:b0:18c:2287:29cf with SMTP id y40-20020a056a203d2800b0018c228729cfmr24133235pzi.40.1701437048009; Fri, 01 Dec 2023 05:24:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701437047; cv=none; d=google.com; s=arc-20160816; b=Zc2TNg1m9PzyBKiwHZIuGEd2sZD+IqJLUJp0Fwk+tKkSazmkhoRNt4A2QLxnVB+JWw Ea/N9iwrrFNn2XEkQ2uGk59Y1SbM4tvXFHoqO4RW+npY3ZH05WTHM6brqGWXXDsaZJiX ySRPZ/EPkmcnjttc96QlBuEBJGK9eqBpqDO5EAEisWW38+oYs5bANlnVJCJVX0cSBxt8 HB7NzBZUW90HiFubZSHM9X+kKOkTmy0RaUJhGJ3maJdpc+DQdk0aP5dvvd2lYFBp9nd9 kCQT/uz2/EV2h07+uxDfkLpOG2MmLtNRks0FqkhZj95Q469cQqs4c2WvTBzKVa9gXynN MYFQ== 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=+kI5BDmKh3jGRdphZFBe/MI3JJ5Ca0dXi+wridfNDLc=; fh=7eaXqqt56dHYACtqbmHJZEk+aycmaLotfnpXo9FMcGg=; b=TKFV2GdNoe1uWMWZZw4SEB6rkG03bxu29RgTOrZmGmDED+yyCWM21oTOGi1dM6DNUh H1N+AunyFqNDazNtNZ2OlF9iVvN98AXy30jd7Io7/Xk9kgFMLPT/RJWos1FwA96cR6FC WbgwKrL9+Mg4MynCAn5TzqTKa3f27Vgde9R1tGCclRM0LG/hLtQslQCVoIO1Q5Bmlyvx jXwwFuU1RcqjS8Kuwjhz+1xAw7u9Dvwx6PQv+7xicTULc2A9Ua3cMRyE3R1UmLwL8AQR N6P7HkdmxsJOYlRX8NcWjrefndcKwDFo9Vuw/3xd4JSMPVVKE2Bjle3ZFxjOe2ZLRF0d c5KA== 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:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id z6-20020a056a00240600b006cb88a16f29si3266219pfh.161.2023.12.01.05.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 05:24:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 299818269C73; Fri, 1 Dec 2023 05:24:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378992AbjLANXw (ORCPT + 99 others); Fri, 1 Dec 2023 08:23:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378972AbjLANXv (ORCPT ); Fri, 1 Dec 2023 08:23:51 -0500 Received: from sgoci-sdnproxy-4.icoremail.net (sgoci-sdnproxy-4.icoremail.net [129.150.39.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 573259A; Fri, 1 Dec 2023 05:23:54 -0800 (PST) Received: from luzhipeng.223.5.5.5 (unknown [39.174.92.167]) by mail-app2 (Coremail) with SMTP id by_KCgDHzExe3mllE0E3AA--.12589S2; Fri, 01 Dec 2023 21:23:43 +0800 (CST) From: Zhipeng Lu To: alexious@zju.edu.cn Cc: Mauro Carvalho Chehab , Devin Heitmueller , Palash Bandyopadhyay , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: cx231xx: fix a memleak in cx231xx_init_isoc Date: Fri, 1 Dec 2023 21:22:55 +0800 Message-Id: <20231201132256.3245268-1-alexious@zju.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: by_KCgDHzExe3mllE0E3AA--.12589S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ZF17ZF15Wr1DCryfZr4Utwb_yoW8Wr4kpa n5GFyUAayDJryDArn8Jw43WF1rA3W8t3s8GrW7W3WDCr1rG3Z5XayFv3ya9FW5Za1Iva4S v34UXrWjv3ZYqa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1l42xK82IYc2Ij64vI r41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8Gjc xK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0 cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8V AvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E 14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU5WlkUUUUU X-CM-SenderInfo: qrsrjiarszq6lmxovvfxof0/ X-Spam-Status: No, score=-0.8 required=5.0 tests=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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 01 Dec 2023 05:24:01 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784086054294551263 X-GMAIL-MSGID: 1784086054294551263 The dma_q->p_left_data alloced by kzalloc should be freed in all the following error handling paths. However, it hasn't been freed in the allocation error paths of dev->video_mode.isoc_ctl.urb and dev->video_mode.isoc_ctl.transfer_buffer. On the other hand, the dma_q->p_left_data did be freed in the error-handling paths after that of dev->video_mode.isoc_ctl.urb and dev->video_mode.isoc_ctl.transfer_buffer, by calling cx231xx_uninit_isoc(dev). So the same free operation should be done in error-handling paths of those two allocation. Fixes: 64fbf4445526 ("[media] cx231xx: Added support for Carraera, Shelby, RDx_253S and VIDEO_GRABBER") Signed-off-by: Zhipeng Lu --- drivers/media/usb/cx231xx/cx231xx-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c index 727e6268567f..f1feccc28bf0 100644 --- a/drivers/media/usb/cx231xx/cx231xx-core.c +++ b/drivers/media/usb/cx231xx/cx231xx-core.c @@ -1024,6 +1024,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, if (!dev->video_mode.isoc_ctl.urb) { dev_err(dev->dev, "cannot alloc memory for usb buffers\n"); + kfree(dma_q->p_left_data); return -ENOMEM; } @@ -1033,6 +1034,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, dev_err(dev->dev, "cannot allocate memory for usbtransfer\n"); kfree(dev->video_mode.isoc_ctl.urb); + kfree(dma_q->p_left_data); return -ENOMEM; }