Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3696665pxb; Mon, 24 Jan 2022 15:38:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNM7pWVyikUDKm6+qDmfMvXsNUYe9IeULX/cXNTabkYHpewu9tPnrVhs65JMt3a/1rBM++ X-Received: by 2002:a17:90a:4089:: with SMTP id l9mr701365pjg.14.1643067496578; Mon, 24 Jan 2022 15:38:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643067496; cv=none; d=google.com; s=arc-20160816; b=M2WEzJurGi8oLD9ZQ+Cdnc2d7otmxjPUr4cEibvr5WX1wr9OYZOIzxnYUBmQtZSU/S g+2KNDi2Z20gZ1ehWI5pOH5v44Ssi+6OfTRw9PZQsMU2ANM9NuAGxpgtMnRzlTSlt0s6 /PNXlGuMZ7X4FITtcmhwJ+k8UkHU3fgut+nfvPE/9uUZRhq4nhBcvfgD/ZYwbG7du33J QhYQcZZAZ/pZyMflDsaYiB0FDUWgyWmgUOWFFo1pLNhif/yy941nsipZrDy6LTo6S6/U Jr0Hl1gW6NL6R6+0jeYhpYMPWUcc/Jo7EP1tg+PXFOHGnDLpFXEW+KJKfM06JP5ij6f7 nvfg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5mVUXcwwUMNluxcadbSu4dMindzr6fEaANmFI/4c91s=; b=cRQs/0LAF4nzHp+d/pFSni/72qkmOtN99t77/amk738tMEMixr8S05V33JLj+PIHrK BT3FjgGnD4w9uxbXWJ3nIojhpiu7mwL01cnv8tJx8BDDhrOtlIWvZoXli9IElp4cyJOQ s/0L4iJlJtXGpUZwhl/EBKpZijHLS4dOtLjXW9SotukqE3DPDa1mxAA81W32egaIKvnX kRADX9OabdaXMFoV22TV+X/C4pFd+8tSdO+ZJ8xz9xz9Xb2Z8BAjX44tTT/GREmbBQxF YRHpyqtFFxgkPW19oBvTNclIO96PeZVOvPHLTtbrShd/CKF6sdCoJ/BACsro1Wxu9CyO VUTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=beR10tR+; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si599866pje.95.2022.01.24.15.38.05; Mon, 24 Jan 2022 15:38:16 -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=@linuxfoundation.org header.s=korg header.b=beR10tR+; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2359640AbiAXXdE (ORCPT + 99 others); Mon, 24 Jan 2022 18:33:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354423AbiAXWlr (ORCPT ); Mon, 24 Jan 2022 17:41:47 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0391C04D63F; Mon, 24 Jan 2022 13:05:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 90FDF60B03; Mon, 24 Jan 2022 21:05:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6990EC340E5; Mon, 24 Jan 2022 21:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058300; bh=F/hEJXjFztjsMlfPfO2E5y342r2bldbSUn26RRHGDXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=beR10tR+1/VatBFJHR3y45Lb027ac9sQu29J7xwxwOiiXKBZ6ViWuqlb4DKC7kKx0 xD36JtSzgKtVq1lffy6KSaHw+JTt908OOpm4nzX+uY/lpZVnjaH8asW3Yt0fg5zncQ AQOSvr8BjG/vUmID9ggvf0ufyVszHGv1AJa8G9pM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricardo Ribalda , Laurent Pinchart , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.16 0245/1039] media: uvcvideo: Avoid invalid memory access Date: Mon, 24 Jan 2022 19:33:54 +0100 Message-Id: <20220124184133.563200222@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ricardo Ribalda [ Upstream commit f0577b1b6394f954903fcc67e12fe9e7001dafd6 ] If mappings points to an invalid memory, we will be invalid accessing it. Solve it by initializing the value of the variable mapping and by changing the order in the conditional statement (to avoid accessing mapping->id if not needed). Fix: kasan: GPF could be caused by NULL-ptr deref or user memory access general protection fault: 0000 [#1] PREEMPT SMP KASAN NOPTI Fixes: 6350d6a4ed487 ("media: uvcvideo: Set error_idx during ctrl_commit errors") Signed-off-by: Ricardo Ribalda Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/uvc/uvc_ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 30bfe9069a1fb..9a25d60292558 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1638,7 +1638,7 @@ static int uvc_ctrl_find_ctrl_idx(struct uvc_entity *entity, struct v4l2_ext_controls *ctrls, struct uvc_control *uvc_control) { - struct uvc_control_mapping *mapping; + struct uvc_control_mapping *mapping = NULL; struct uvc_control *ctrl_found; unsigned int i; -- 2.34.1