From patchwork Tue Apr 25 13:25:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 87403 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3406892vqo; Tue, 25 Apr 2023 06:31:36 -0700 (PDT) X-Google-Smtp-Source: AKy350b8rRGWCTl4FslJfvJ6mtfAy+gHIe9AA4Ap61vtME1Hcirh9a5IqBt85Rqpz3bczCuNxVOZ X-Received: by 2002:a17:902:c951:b0:1a6:dc4a:b8fa with SMTP id i17-20020a170902c95100b001a6dc4ab8famr21205640pla.54.1682429496597; Tue, 25 Apr 2023 06:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682429496; cv=none; d=google.com; s=arc-20160816; b=t3yB3uIwwwu4L6UAfS9GQYK8zwXkjcCrDV2ioaTZmh4bKUe/mKNKd0YpIhpz3wGdS9 8wUcS73HeJJLp/9gyVAPSpf/IqTY5hqWcHraI+LICuuXM2l4N8cVKXXcjMA0PegjileF w0VR95Zd/WIFwAsRETRKAsJyGpNIjfzKNZTeQUz7/fWwgKMU31lh11R0bH7bLENEITHA WWCyb8O5P2cU2Ik+6tdWnNRjYskibfjokzecyXkrCXGJe8Lk4TH5od+7kqNgQv2b6yoF cc7Zu9hykO1cRKyzFLM6u2/HCO/DqfZfewgqv4iOS2O0JfnQcKXnxzeg9TnpHHtuPAf3 g78g== 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:dkim-signature; bh=0CeXjHqICQk7DLJzz6VjSF2+bjOODLrldPjkrHUYBUc=; b=H/OgWxmbb2eYTfvHMXU4GvuPlx8AGOacC/VRLSCf9G5BfDeLOKOLRQWLzFTSdR/PDi 9FsKshwRVPEr3NuM/to5jsvn1JQnIaQjUBAlYM0b6lupnvRQ3z7NRJxJ+6IzTA3qDR31 Aq9UoJLPaEu2jrwgW1tEZ7nUnHXK3rEZxqDtgn54QJ3WJZIDy1rIF6N2ASqdEFdRpsdb RPbYUncAvxFnKcW92WZGx2bDLIMg8ZmwwuQ4SQ4seCxiy2SB50DUB1FJKxNsaM3Bxuvi dchFz5goc+4eRCz4fUBFH36sBtpmuVZXgkbuuf56SyFWQIMC5iQ7ZtwXFGYWqYBdk5Tj MMeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=j3P89YII; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a170902d50f00b001a987c1bf5esi2850883plg.270.2023.04.25.06.31.23; Tue, 25 Apr 2023 06:31:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=j3P89YII; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233329AbjDYNZz (ORCPT + 99 others); Tue, 25 Apr 2023 09:25:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjDYNZx (ORCPT ); Tue, 25 Apr 2023 09:25:53 -0400 Received: from smtp.smtpout.orange.fr (smtp-11.smtpout.orange.fr [80.12.242.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5B3313C11 for ; Tue, 25 Apr 2023 06:25:49 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id rIfzpNZfxLbpDrIfzphTyk; Tue, 25 Apr 2023 15:25:48 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1682429148; bh=0CeXjHqICQk7DLJzz6VjSF2+bjOODLrldPjkrHUYBUc=; h=From:To:Cc:Subject:Date; b=j3P89YIITwZY8lXV2Qx7n2LRfrMAL9l2sK9ZcSA6ql20V09I4b1H2XyewoveyDvrS 3Zig775onP4tYCUdbtNBw6ATUBqf4iVKHoWnbpgUHJLJBX1K8EVBTPt9XmbolmhDPz f+cC1Dbyq+BFRdhlsIvm0TYD9DcwmlvBXye5hKvpt12H28ZrvInjPs4ybPJGQdvPlr SXrLmijp4ZIKmriKBiQiysf4ythMRBchAW7IjbZ0EuWWwkBw/EeK1fc2Th4mikNNrN qy7OtkQfb9J/ysAzrFuq9MMa9UfiqfNb0BWz80/h1W5IuumK9W/xnkOCCOLbGGmS2v 8MkpGYKCGpv0w== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 25 Apr 2023 15:25:48 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Hans Verkuil , Mauro Carvalho Chehab Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Hans Verkuil , linux-media@vger.kernel.org Subject: [PATCH] media: common: saa7146: Avoid a leak in vmalloc_to_sg() Date: Tue, 25 Apr 2023 15:25:46 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764155191973869391?= X-GMAIL-MSGID: =?utf-8?q?1764155191973869391?= Commit in Fixes turned a BUG() into a "normal" memory allocation failure. While at it, it introduced a memory leak. So fix it. Also update the comment on top of the function to reflect what has been change by the commit in Fixes. Fixes: 40e986c99624 ("media: common: saa7146: replace BUG_ON by WARN_ON") Signed-off-by: Christophe JAILLET --- drivers/media/common/saa7146/saa7146_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_core.c b/drivers/media/common/saa7146/saa7146_core.c index bcb957883044..27c53eed8fe3 100644 --- a/drivers/media/common/saa7146/saa7146_core.c +++ b/drivers/media/common/saa7146/saa7146_core.c @@ -133,8 +133,8 @@ int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop) ****************************************************************************/ /* this is videobuf_vmalloc_to_sg() from videobuf-dma-sg.c - make sure virt has been allocated with vmalloc_32(), otherwise the BUG() - may be triggered on highmem machines */ + make sure virt has been allocated with vmalloc_32(), otherwise return NULL + on highmem machines */ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) { struct scatterlist *sglist; @@ -150,7 +150,7 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) if (NULL == pg) goto err; if (WARN_ON(PageHighMem(pg))) - return NULL; + goto err; sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); } return sglist;