Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1093179rdh; Mon, 25 Sep 2023 03:07:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBMZchhaRQ8RZ4QApeICkG+D7hCaLsdUHIDehER3yoxZsLesL3CwbBhxUiWxuTvHZxg/9W X-Received: by 2002:aca:1c14:0:b0:3a7:250a:7948 with SMTP id c20-20020aca1c14000000b003a7250a7948mr8578073oic.13.1695636446089; Mon, 25 Sep 2023 03:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695636446; cv=none; d=google.com; s=arc-20160816; b=0QNUh39qyylmt90EN7u3P1DZ3D2dUvQ2NjmCrShJjL1nI8zQqIiGPgw7r2/S+2Btfo YFfRa7hFWrK6+TgCuoJg6QepRj9HyiFv8yqwscxQSjGWVPx+nlLpqDN1kHDW++p0363k jxKmsW7q4I499dLS3AZjDdx6pAA+MzAy0YsoRWYfaXTQAxC+6q+rEMmQh+dlfWwBB+D6 vw2MYB05JlVPH2K/HkNly2lcSUbzfn/DKrhaBkZsGwskTAMuWMURwIicKA56K39AHIMe XdOhV9OFVmlz9bNozAZmgTuf+4hHtkckZ/dYT6tNUxy8+1ouORRoE1VvvEm8m5Qu2syM qaLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=v1fCYqedYzzKO4/DatWZ9evuoKqCZkc7HSmVchjhdJY=; fh=BGjda7DLoq7R7/NRZ4neswTrDV581AvtT7WmjQUuYmc=; b=HXGL06BqxMyqr9FOVAEzllUKX4HaNOScv2hrLiRmNhVwN8c1VrlviBxsh9DYv5zl9z p2cfC1OI9zZXO1xk9PimSOIGqIYyaI8TebRTdn0sq1lCf/lN0AdYdj3pBa946sMWR995 vpUmX/vK8E3sIv0TTW6OaEYGwXtucHqPL26TERaCPi9b6QSOhssLJZ/Hn/3hzCe8hoUQ 2OUj7Uf+oJ1lpOKtrTyO5Jd7SCWdQzlkX83THEAkYW74dy+EJhCbhh1kUb+ZUMBEsnGt FJzel3xzqFHvnkYWjsK/ewnQLX74ydGaZHWINgEHDOa1UNGVvlGCXD/eLF33YH975Lx0 cDJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 19-20020a631753000000b005789f94cd34si9592674pgx.636.2023.09.25.03.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 03:07:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E2AEA809E737; Mon, 25 Sep 2023 02:55:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbjIYJzW convert rfc822-to-8bit (ORCPT + 99 others); Mon, 25 Sep 2023 05:55:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjIYJzU (ORCPT ); Mon, 25 Sep 2023 05:55:20 -0400 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4980A3; Mon, 25 Sep 2023 02:55:13 -0700 (PDT) Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-57b691f0fbfso545167eaf.0; Mon, 25 Sep 2023 02:55:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695635713; x=1696240513; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lEzI9WPuDjrFxx8ftRmrx4d1R9NKDCnLQme3cQmWWOY=; b=O0a32u666FYJlJUsNHWf6jOpEwqKBhm6o5rfNZI6c7EaVSU7ntqkKmmJL7B54nPqcy xPu1kg/Um2LknljHcMyA1i7FVWK36su7ZG32Sb2PHgr0DoxG2GeRNJG1FysJ2oKebaUG EaSy7Wmvrl/46/+nYFvTA4pkDzP9nouWXkGlNhsP72PAaKSgwsXWuaEqpWxG9R/TqeHU 3bUFBXHE2tfIJk4H2ozLThEfk8e3QUnHF1ZTz977g2r1WrfU88t3awIvhtuE9Nz0hwf6 Ihjf3nPeLsAtkt14syWkpowG6O1UL37pUBl7PDkSEOHbKfdm0eVLJ2U2dm699EWNECMe XkkQ== X-Gm-Message-State: AOJu0Yyaz04mpuKOZiI1WUdwnXnz2n1hhCTja3bdDClnIze0IIk/DfsV mvLLTKssdrmoRz68ZQUrq8fRfpJfHAEx4Ewhkpk= X-Received: by 2002:a05:6820:1a9f:b0:573:4a72:6ec with SMTP id bt31-20020a0568201a9f00b005734a7206ecmr4733855oob.1.1695635712946; Mon, 25 Sep 2023 02:55:12 -0700 (PDT) MIME-Version: 1.0 References: <20230925080844.32699-1-dinghao.liu@zju.edu.cn> In-Reply-To: <20230925080844.32699-1-dinghao.liu@zju.edu.cn> From: "Rafael J. Wysocki" Date: Mon, 25 Sep 2023 11:54:57 +0200 Message-ID: Subject: Re: [PATCH] ACPI: video: Fix a null-pointer-dereference in acpi_video_bus_add To: Dinghao Liu Cc: "Rafael J. Wysocki" , Len Brown , Michal Wilczynski , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 25 Sep 2023 02:55:19 -0700 (PDT) On Mon, Sep 25, 2023 at 10:09 AM Dinghao Liu wrote: > > acpi_video_bus_add_notify_handler() could free video->input and > set it to NULL on failure, but this failure will be missed in its > caller acpi_video_bus_add(). As a result, when an error happens in > acpi_dev_install_notify_handler(), acpi_video_bus_add() will call > acpi_video_bus_remove_notify_handler(), where a potential null pointer > video->input is dereferenced in input_unregister_device(). > > Fix this by adding a return value check and adjusting the following > error handling code. > > Fixes: 6f7016819766 ("ACPI: video: Install Notify() handler directly") > Signed-off-by: Dinghao Liu > --- > drivers/acpi/acpi_video.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c > index 948e31f7ce6e..b411948594ff 100644 > --- a/drivers/acpi/acpi_video.c > +++ b/drivers/acpi/acpi_video.c > @@ -2057,7 +2057,9 @@ static int acpi_video_bus_add(struct acpi_device *device) > !auto_detect) > acpi_video_bus_register_backlight(video); > > - acpi_video_bus_add_notify_handler(video); > + error = acpi_video_bus_add_notify_handler(video); > + if (error) > + goto err_del; > > error = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, > acpi_video_bus_notify); > @@ -2067,10 +2069,11 @@ static int acpi_video_bus_add(struct acpi_device *device) > return 0; > > err_remove: > + acpi_video_bus_remove_notify_handler(video); > +err_del: > mutex_lock(&video_list_lock); > list_del(&video->entry); > mutex_unlock(&video_list_lock); > - acpi_video_bus_remove_notify_handler(video); > acpi_video_bus_unregister_backlight(video); > err_put_video: > acpi_video_bus_put_devices(video); > -- Applied as 6.6-rc material, thanks!