Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5637092imu; Mon, 26 Nov 2018 03:20:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/WywECC47CLVvmgcoNBWok10N/tiHKZg6uTFg5/9fPcA9FKpTvth22pu0VIkb4JJxZ7xL+A X-Received: by 2002:a17:902:6bc3:: with SMTP id m3-v6mr7850547plt.106.1543231222735; Mon, 26 Nov 2018 03:20:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543231222; cv=none; d=google.com; s=arc-20160816; b=dAAqjDfeLb9ZI0q35CPfZb7taPSqCOlzcyQjC2M+wsYjX5hxFm64njgJehkxVSj8/k OI0cfALnc9AuJZtxGbDUvHrCFgTkKGAY44VuQfN6lSkhTK+XcTVclC64nRrfqlDrJxkI eKHqvCL77M3cjGlte7Un4FsC5XK0c/RR8n0aH3dqhFywnfqZeRrDAghGIqezTxymHRF1 AUWFYBs1U36N/uctKjCyxTfMCGnth4steEEHN7sbbwy26dLJpD/ycnWbbPwK9ZFt1X3w gkG+VcRs6Ue+gfPUZOmsYKQf25iMV8NB2Bh78NcxRT5WH7uPB/4LGmgTFKeBHd8eQSDj zpqw== 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=rXtGV20o3VxMjvsZAhUO5kiNtHbSDH68/U5htM7i4lQ=; b=DrWus+YK+WhGGMBu/8HzKOauW7sev/NNnJ9jchH9wRCGXaByViCs67xl5eOBtPseTq /hRO4NmSlfXLaeQmfLcJIcDJW8vZY1ZrSFFePQl9icgDZALGhlDOkcODYfUOs4RRukKf QVArG9q7Hhza4Cxw5R1U2MAc+ls33BkoXRebvhTvFXgkb8gkK6jHYA2boacpSBvazzpf GsIXdNou8dpNzWSBJ4eUwd57C6qXV+mN8jIzb+j2tzuKUjBV71cql0itjoD0/fnK3Ux4 4T6gNl2B7fVnoGi/p/Qj6Fc08/BdtCSRsWcUiepfRr4m6sH040baPtFagkqn/LkqCLxJ 50Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J+8Bl28E; 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 b3si61349706pgc.587.2018.11.26.03.19.56; Mon, 26 Nov 2018 03:20:22 -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=J+8Bl28E; 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 S1729961AbeKZVyh (ORCPT + 99 others); Mon, 26 Nov 2018 16:54:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:36850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbeKZVyg (ORCPT ); Mon, 26 Nov 2018 16:54:36 -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 08F6F2146F; Mon, 26 Nov 2018 11:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543230051; bh=Wm5W+a2i+LF+HTyV9NMZx3LUXhL58Pb28D8GgBtXWA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J+8Bl28Ec3rZfhTyqkcqVh1GcyR+/d/8kWeWMP0hD4Knso4PzP43kLdpstkWXeaCs SdvNgW0OEcUIuXs6LexDAckerqoMWc76UE2qgl7pxxsx0Qn+FqPU3gNxaqAm+nO75g y5gszKVN1j4c+/AzvGQJSATZ8Vx8LXJy8a4IR/Kc= 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.14 52/62] uio: Fix an Oops on load Date: Mon, 26 Nov 2018 11:51:33 +0100 Message-Id: <20181126105054.603577007@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105050.592727680@linuxfoundation.org> References: <20181126105050.592727680@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.14-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 @@ -850,6 +850,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 @@ -861,11 +863,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: