Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5626189imu; Mon, 26 Nov 2018 03:11:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/V0R3KyxmZwksax+JojinXBwOcKBJQfEMazAUaKUOScwxTcRc++SRQJAPpxiMQpnQjPbn9Q X-Received: by 2002:a63:8ac4:: with SMTP id y187mr24534150pgd.446.1543230667367; Mon, 26 Nov 2018 03:11:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543230667; cv=none; d=google.com; s=arc-20160816; b=J/B5j3WKZKgOUlX4CYwXmds/vOx3HGpZPCFEOMmBeGppLmtqJIK2vu3mYMIGtKnFyC tyEwETDOr8Hd+5l38ww8P6EoX+TiXlFYs9Nn8psGjx68bv4EkgexPBJDhsv1B003xinC eVAllJWI4YDePeE+dmsy4nV7m3IfdX4x/j5nd8z1m26/5N6hQWFeqe3LLkhnCMLWeGx+ nFSLZRQzANpYf3WA5Y9EI/p6FQMVPi6iB3hFFdpTrOLEFnAh4hPBAW1HTdIVO8f4vF4Y bWW0mohGOZupCp8jB9qWTgPudSOVUhgYZZvCEVMD80qaidtF4JNMBnV2R7+mx4Ldnv8t nXvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OH/tz1LNZWLZ1NJNzs57c92j2vlCFTTUdOCrf2PyzCs=; b=KqSNqp2GYqPhxYYc3AG1CZO/I3y5MhP6mDFuvIWCXXyZUpQwg0aaltdkVNFJwTSa2L g6/1xhJeMH6+/PsnjrEwAK/aeMQ1ltgZiV7QsHKPL77srHbg584x+kjcwwj+oaqYSoUq P0scXC2hPJfyrtn56VVRk2rP5+sAt1TKCyhIaW0DXkjut9NPHBNvmety5s6IoGMv8Nio bfADMMOaZRENKk2ZLEc3DS2qZKqE42nS4w0/U52HYFB5TkljDSTTaPnfvjP5R/7wxPaH S69r+ZmnK41b27p5ktCCPFqWzYvH5tcmfJI7IGeE0wCyGuLxuTleDmBgVNN5GcAhCT5/ 35ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jY+ZfKcU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b65si60498380pgc.259.2018.11.26.03.10.53; Mon, 26 Nov 2018 03:11:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jY+ZfKcU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731058AbeKZWCN (ORCPT + 99 others); Mon, 26 Nov 2018 17:02:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:45460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730303AbeKZV7Z (ORCPT ); Mon, 26 Nov 2018 16:59:25 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8BF9A20672; Mon, 26 Nov 2018 11:05:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543230339; bh=+i0ZO11amGJvZsME5A3b0yD6R50OP1DWjp2u05RPv60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jY+ZfKcUy83HTlA1sVE7enzYVGQlj6Wze+efBN6TdyAQRDnR/ty2H6vWJiC8qj/SG cspnJdgV01534UuU/wKJ8apuUlXBfQL63tmJ1doSa8UMHVvpqWcCZ1HgFmkDrW9M0x W6o6jjuv9HJoucjQybPmIg2bM6YLwYq4lcgPDfQI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Thore , Dan Carpenter Subject: [PATCH 4.19 098/118] uio: Fix an Oops on load Date: Mon, 26 Nov 2018 11:51:32 +0100 Message-Id: <20181126105105.632882223@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105059.832485122@linuxfoundation.org> References: <20181126105059.832485122@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter commit 432798195bbce1f8cd33d1c0284d0538835e25fb upstream. I was trying to solve a double free but I introduced a more serious NULL dereference bug. The problem is that if there is an IRQ which triggers immediately, then we need "info->uio_dev" but it's not set yet. This patch puts the original initialization back to how it was and just sets info->uio_dev to NULL on the error path so it should solve both the Oops and the double free. Fixes: f019f07ecf6a ("uio: potential double frees if __uio_register_device() fails") Reported-by: Mathias Thore Signed-off-by: Dan Carpenter Cc: stable Tested-by: Mathias Thore Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -959,6 +959,8 @@ int __uio_register_device(struct module if (ret) goto err_uio_dev_add_attributes; + info->uio_dev = idev; + if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) { /* * Note that we deliberately don't use devm_request_irq @@ -970,11 +972,12 @@ int __uio_register_device(struct module */ ret = request_irq(info->irq, uio_interrupt, info->irq_flags, info->name, idev); - if (ret) + if (ret) { + info->uio_dev = NULL; goto err_request_irq; + } } - info->uio_dev = idev; return 0; err_request_irq: