From patchwork Sun Sep 24 12:44:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ma Ke X-Patchwork-Id: 725991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1EA9CE7A88 for ; Sun, 24 Sep 2023 12:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229717AbjIXMpl (ORCPT ); Sun, 24 Sep 2023 08:45:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjIXMpj (ORCPT ); Sun, 24 Sep 2023 08:45:39 -0400 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.216]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5A5E3115; Sun, 24 Sep 2023 05:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=+2Z6h zNWL+7AHOQl/szTVZWNb/9TMPRypWtQCppNa4Q=; b=XXlzUobatS3E7yDcYcWPj 3Rz5JYqeyHEY8g/9dLAs2NaiSKRbsO3YwOxFEfEHWvSvnXbCq0iOnG1Z9NRFY+uM T8xqHineiXSguMS5eLDA+q/dR4+g1bH+EARi3V3AfNPgxhcJXbPNj0iyojmEBiRf zdfuEctmmJSzkR4iiV7nq0= Received: from icess-ProLiant-DL380-Gen10.. (unknown [183.174.60.14]) by zwqz-smtp-mta-g4-3 (Coremail) with SMTP id _____wC3HGMsLxBl7_DWCw--.17004S4; Sun, 24 Sep 2023 20:44:42 +0800 (CST) From: Ma Ke To: tfiga@chromium.org, m.szyprowski@samsung.com, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ma Ke Subject: [PATCH] media: videobuf2: Fix IS_ERR checking in vb2_vmalloc_put_userptr() Date: Sun, 24 Sep 2023 20:44:25 +0800 Message-Id: <20230924124425.3664024-1-make_ruc2021@163.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-CM-TRANSID: _____wC3HGMsLxBl7_DWCw--.17004S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrtF1ftw18KrykCry8GrW7Jwb_yoWDJwc_uF yDX3Z7uryUWF1rtw1jka1S9ry0y3y8Wrn2gFnYy3s3J34UXa93Zw1qvw1ftF1I9a17A3sF vwn8WFyUuF43GjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRWHq7JUUUUU== X-Originating-IP: [183.174.60.14] X-CM-SenderInfo: 5pdnvshuxfjiisr6il2tof0z/1tbivg70C1Zci1ttGwAAsj Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org In order to avoid error pointers from frame_vector_pages(), we could use IS_ERR() to check the return value to fix this. This checking operation could make sure that vector contains pages. Signed-off-by: Ma Ke --- drivers/media/common/videobuf2/videobuf2-vmalloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c b/drivers/media/common/videobuf2/videobuf2-vmalloc.c index 7c635e292106..c37775080aff 100644 --- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c +++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c @@ -134,6 +134,7 @@ static void vb2_vmalloc_put_userptr(void *buf_priv) if (!buf->vec->is_pfns) { n_pages = frame_vector_count(buf->vec); pages = frame_vector_pages(buf->vec); + BUG_ON(IS_ERR(pages)); if (vaddr) vm_unmap_ram((void *)vaddr, n_pages); if (buf->dma_dir == DMA_FROM_DEVICE ||