Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp983292rwb; Wed, 7 Dec 2022 07:19:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf7FVWaBcYHPOru70Et3BRruMSa6QrIEb1cfWI2i9R5cXdvQ6IfvP93A2m0ycHKseDusps+E X-Received: by 2002:a17:907:7759:b0:7c0:d6b3:3bba with SMTP id kx25-20020a170907775900b007c0d6b33bbamr15449264ejc.714.1670426369903; Wed, 07 Dec 2022 07:19:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670426369; cv=none; d=google.com; s=arc-20160816; b=WtHlnRp1l8We+MEep0DDQsekM6IpLr58XwBF2FrDlO92y9kKNH/8EQPoOZ5AX1iPYf JqqzZlGUEAIjwBgfReh32q51nGb1GD+xIovd6ZKQmpZRm49F14RNqe1RyBkI6rUuecCl mAF2AVnv7sXuWYQy6BLaZUcXcD78yV5UT2ryelRcU4N5As7AMTROr0yvqGFnUKXJNgSK Wka8AF0wsBpvpHm9ecL6rQKSqNoq1QPIjuGrNTFo7/XI0kw5QoVEe4SLukzl0eIZGY8r OKM+/J9NQBBp5l1tPG1mGl2XpvKB3FHqWQdNGA9Yj0E3CE9lQ7AZdIKEqsEpzDsgP1DL GyaQ== 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:dkim-filter; bh=w/yclODkCgJWPfVa/yWAmC2/lYgiHSNRxjwj97Pe/0M=; b=0TAPqmkTZSvQ8HG4niqql5FZCxF7KI/ooPOqnDh6Hu4awo/SNu1/MXBIE152IU3Zou GHiiDll7VHFgK09be0SyfJKtWk96PyDSxyLaxu6bKQNEj2KyBnuJ1mSFxlsmsWDU7IUa XPDVpyHTU5GOvai2brXejB9l4USVYrwHFIrWualBsk8TG5dUGysXBbG5aBWa+avNERxn XEx8qxCi39kmX98wwo2Shre7D8Xj73OKGcreLnOtEyfdNUly1qM3naJppfwGiVtkqZ6s 4snuSuUXcC+1Gpe0MeFjpH31pXFPfr8MywhsRxXE9r4tGF8v9bKzMbKGG2GGp4C7WxZi ywPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rosalinux.ru header.s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503 header.b=hbLN8cD5; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rosalinux.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170906854b00b007c115fb9d63si2295457ejy.392.2022.12.07.07.19.11; Wed, 07 Dec 2022 07:19:29 -0800 (PST) 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=@rosalinux.ru header.s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503 header.b=hbLN8cD5; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rosalinux.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230296AbiLGO3L (ORCPT + 76 others); Wed, 7 Dec 2022 09:29:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230342AbiLGO2n (ORCPT ); Wed, 7 Dec 2022 09:28:43 -0500 X-Greylist: delayed 610 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 07 Dec 2022 06:28:33 PST Received: from mail.rosalinux.ru (mail.rosalinux.ru [195.19.76.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFDC6326F9; Wed, 7 Dec 2022 06:28:32 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.rosalinux.ru (Postfix) with ESMTP id 728FC5D88BFE; Wed, 7 Dec 2022 17:17:03 +0300 (MSK) Received: from mail.rosalinux.ru ([127.0.0.1]) by localhost (mail.rosalinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id QonOtwzX_AXI; Wed, 7 Dec 2022 17:17:03 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.rosalinux.ru (Postfix) with ESMTP id 40D4D5DA93A0; Wed, 7 Dec 2022 17:17:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rosalinux.ru 40D4D5DA93A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rosalinux.ru; s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503; t=1670422623; bh=w/yclODkCgJWPfVa/yWAmC2/lYgiHSNRxjwj97Pe/0M=; h=From:To:Date:Message-Id:MIME-Version; b=hbLN8cD5C+k+gvhwBaPqC/QawC/Hsmh/Xljnq2w6WC9xGtixO/dbbkcQhZaB6jjb0 j2/f3B6Bo8BGNOw+/8dCnd/yw+jtNWtiP7b1b1MhLsu48N3PO1RbnCjLfrGlTQnGgp 30XP8l7NNt2YjLfhmYMAMQ6c8dy82xnqtWGMlwhC2BbknTU7SiQOT90o3dmLHeWyA6 fymtzJnpx/0EwvVRvbdPMP2LmHnoBc2vV37I+/auIHQM1SCsisRwLiv5x/k6rdpf9h 8aCv+TbTii02CXyVRBk60PoXuFRc6oWs8UGzuh/EFdQZu3xA/LM9s3NOfbJeyiftk5 NPsHEepkGBVIA== X-Virus-Scanned: amavisd-new at rosalinux.ru Received: from mail.rosalinux.ru ([127.0.0.1]) by localhost (mail.rosalinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id V30dyoE9cVKj; Wed, 7 Dec 2022 17:17:03 +0300 (MSK) Received: from ubuntu.localdomain (unknown [144.206.93.23]) by mail.rosalinux.ru (Postfix) with ESMTPSA id 00F055D88BFE; Wed, 7 Dec 2022 17:17:02 +0300 (MSK) From: Aleksandr Burakov To: Mauro Carvalho Chehab Cc: Aleksandr Burakov , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] media: v4l2-flash: fix NULL dereference in v4l2_flash_s_ctrl() Date: Wed, 7 Dec 2022 17:18:07 +0300 Message-Id: <20221207141808.22922-1-a.burakov@rosalinux.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 The NULL check added for fled_cdev before dereference. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Aleksandr Burakov Fixes: 42bd6f59ae90 ("media: Add registration helpers for V4L2 flash sub-= devices") --- drivers/media/v4l2-core/v4l2-flash-led-class.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/med= ia/v4l2-core/v4l2-flash-led-class.c index 355595a0fefa..36cc46e80eea 100644 --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c @@ -291,12 +291,16 @@ static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c) * No conversion is needed as LED Flash class also uses * microseconds for flash timeout units. */ + if (!fled_cdev) + return -EINVAL; return led_set_flash_timeout(fled_cdev, c->val); case V4L2_CID_FLASH_INTENSITY: /* * No conversion is needed as LED Flash class also uses * microamperes for flash intensity units. */ + if (!fled_cdev) + return -EINVAL; return led_set_flash_brightness(fled_cdev, c->val); } =20 --=20 2.25.1