Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2862720pxb; Tue, 9 Mar 2021 12:53:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8dxq1PVokCvjEeXK15GYKAGFs1BLudppVZ3As8OG1nlHhIAVvge7/vvCU+xK5eQH9QPiq X-Received: by 2002:a05:6402:5255:: with SMTP id t21mr6401834edd.91.1615323182199; Tue, 09 Mar 2021 12:53:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615323182; cv=none; d=google.com; s=arc-20160816; b=zbcHq2xRBvvGsgLSZDZ+JsaTrLgG+2Aa4iEkH3hDeCrJyFdrPk6FvXZlQk1Uf6JmA3 evNcbX660LheHvPuLHYFoonV/tbH7QOzmAMXOY5ZhR+XAE+aINyE5/WAJwUMlmhydxXm Jd5EIovvXmgx3frhUhq93rIK8U6U6nfdxWFMS4IG94VLhwB3za/63JXnJXw+3SvQmJIQ z5SNS8ItbE+Sn5SCieLwTOsm8zrnCqnqHS5qh1k6+VOPBRuQ3ZkN+edYnp5D5/4Qwc1+ LsOome8hs+eqOFyXWlT1Qi298nE5ZrDhyZ6a2fk2RgtgDWbQzv/Q69hysgxUsIRPMlPJ k/CA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q+LXPS2g/C2kk8K3V/x2NSnGympAYYgTq9AwkJ/pVJg=; b=yjSU3yvwmmtYQR7NvCzNPvWYfjB8sYeLWUJS5fE4KNJQEBizKQBbDaTM4AV6u6TEJV /kIxxHIoZJJJe1yD9TxEuza7hP/+iBipf83YE9ntrW1dTBGkWYhDsDMBekZZVHVyPDc+ epMA6ii24b70lSv/FcFoxM6FBR3J2Absxttqof0i0+sEaSvLHtA4bKZQtGUWxCx1/gut lVe2snt9dq+WC/xqDsJA24F4st7kMtOVs0PZTmvhunRf3RsMrrvwa9Di/KAsryJr4rIL LWXtxt0yEyNKxiVJyapsmjAxXgjv1SKYcMcXaQYRLSpHlYyWtx1cx51MWco4HJlqJOhV z+gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K1IwR7ne; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ka21si3870230ejc.323.2021.03.09.12.52.39; Tue, 09 Mar 2021 12:53:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K1IwR7ne; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231847AbhCIUvj (ORCPT + 99 others); Tue, 9 Mar 2021 15:51:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231785AbhCIUvN (ORCPT ); Tue, 9 Mar 2021 15:51:13 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 827CFC06175F for ; Tue, 9 Mar 2021 12:51:13 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id h10so23137981edl.6 for ; Tue, 09 Mar 2021 12:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q+LXPS2g/C2kk8K3V/x2NSnGympAYYgTq9AwkJ/pVJg=; b=K1IwR7nekABeEPYTpc4sfCNOmMmM69FNHkZxRzFj0qH5RZWU9XImYZzmlE0RnWRh03 F0CTTqCA0DSvbgqIBvUzbrZXpvHL1YQJEs9xGLp83Z5EbjgQjwPiEVTTuLNLmFa9QNmh PhaCKqXzEEY5ATbSploSh7okQTotlAOa7D8ro= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q+LXPS2g/C2kk8K3V/x2NSnGympAYYgTq9AwkJ/pVJg=; b=Mu17gjKeo/2dsuFvnLSlfTQ74YoNYwDLs1y8XI9lJQ/fCgQSGC+keRHPp279tzrzKx S99cSm+IjnciTLb2UsK6wv9fIKTBOfSomT58Tv3s5So140c9HCIu5ctuliVBMOy8HabR U88FwQjf8mrrg9rHwpE3Av7RaDp/nOc2knVUJ6r0sIw1j2mf0me12QNiDHmVWTAlVFRt ONaFNWS6AJNTto6lF6Hfw+aSKw/Q/2MOVQytNxY9aqIJgS3KIMJpWaRTK1jplP+UYAWq pHgvBRPy8SHaOekaHUX/YQ+nw9cjYiAY4nOXHIjov9cLtvc5KQ7X8Ymiaw+XtIgNOXg7 y8Yg== X-Gm-Message-State: AOAM530kLkoy9liBBBR2qrNmDR+wyt669EKeTKilPpRDbC05pLfVcHoO EL9Mei3p38b4w3NI7/CUzBXq4Q== X-Received: by 2002:aa7:c6da:: with SMTP id b26mr6426641eds.254.1615323072076; Tue, 09 Mar 2021 12:51:12 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id mc10sm8861190ejb.56.2021.03.09.12.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 12:51:11 -0800 (PST) From: Ricardo Ribalda To: Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Daniel Vetter , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Subject: [PATCH 2/2] media: videobuf2: Exit promptly if size = 0 Date: Tue, 9 Mar 2021 21:51:08 +0100 Message-Id: <20210309205108.997166-2-ribalda@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210309205108.997166-1-ribalda@chromium.org> References: <20210309205108.997166-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Exit as soon as possible if a driver wants to allocate a buffer of size 0, and print a warning to help fixing the issue. Signed-off-by: Ricardo Ribalda --- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c index 030e48218687..c5b06a509566 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c @@ -105,7 +105,7 @@ static void *vb2_dma_sg_alloc(struct device *dev, unsigned long dma_attrs, int ret; int num_pages; - if (WARN_ON(!dev)) + if (WARN_ON(!dev) || WARN_ON(!size)) return ERR_PTR(-EINVAL); buf = kzalloc(sizeof *buf, GFP_KERNEL); -- 2.30.1.766.gb4fecdf3b7-goog