Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp646496imu; Fri, 11 Jan 2019 06:44:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN5wcqQfZudNBvAQslP/GkcYoxcw+F00fzvn2ufsXlHfBGCcej9RjcAOcm+qphpm9GUL1/Pc X-Received: by 2002:a63:d547:: with SMTP id v7mr3467321pgi.339.1547217892592; Fri, 11 Jan 2019 06:44:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547217892; cv=none; d=google.com; s=arc-20160816; b=DfvpL9kHFGwKHEmx93bxFSNa+EenP3Yb1/FQQgojSpKB7RNlSmDcorIaCxAdREbe+8 +iR3hUmDNywKryLA9nA9KZQUZ+BAIGJNJA1PWbGeVMjPKgtaoH1/fuJOrk67jLum2Zof Lbl8GXwOZ7LHqByH5tqql5UaC1GXzl3eAJ0rNSrcQ8zbiaEuRCc3O6U+cPN2yVfXk8+f IDAWPnGInckZg6ifsJMo89oDLPJLcVHChvNAOZTd/4HzBy1nx2cCmYldISYT6HfHgwn9 V94XqFryA7Yl+1ON9VJHWhilQxYt/Yyy/7CQSOMtbowiJBsvAbpLnU5+wwsK6S0s0fBS jISg== 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=Hw4K41b+A8F3uqZEfZL7JKvFojPiw/buqdN4soaAKdQ=; b=eZbBkutxfzPi/Bz0x9ZvLBXBDRHYwzXIT3P2UMpVrlU3FnChLnxhAj2K+FhUo9RQh/ opIWYE23k/dW2hI+ujvuOVGUf36zDQDf70N2nUT8xqMbzh3wtV7dpZoCv57UTtwGnC9T q8pnxWdlCgwsiTxb3neZgeKel3hC/0L3N+5f7c9P04ZhdbmWzBnftT+Vkmhh02+JHV4a 5qjJl6UVX7UGvwJZv00Rg8JA+lFRMCwDjrQpbeTbDZdFi4R6RtWeH+sVyNCYdpfR3IwY 9PuK8zFeBuF2wic5UDpWBYs2bw2NIgji7dp2GvNDTba9fy+3ZozCCX2+s1VBcZApLhVA cEYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j+s2++qO; 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 r39si8868025pld.434.2019.01.11.06.44.37; Fri, 11 Jan 2019 06:44:52 -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+s2++qO; 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 S2404255AbfAKOmv (ORCPT + 99 others); Fri, 11 Jan 2019 09:42:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:35534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403847AbfAKOmq (ORCPT ); Fri, 11 Jan 2019 09:42:46 -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 0DCAD2063F; Fri, 11 Jan 2019 14:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547217765; bh=LE1Di3SxB5ExhGbspW9AAj8GtPuEF83SGNSxZ7p4nmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j+s2++qOYfzDU9+tpiaLTG6NyDUDMeYcG3XGWMKuiemUXzMWo3x8syj2CPRtQplm5 RPI66NGqKTDC5r04Q70hKwFiHLnnWtpTQhI3aGXKt+7jmnnRdbxWEZc3o/44QqoavQ 14/y67h5+PXVpnfP9P3oRQDP7Vvw6juu9fedr0TI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Minchan Kim , Sergey Senozhatsky , Joey Pabalinas , Andrew Morton , Linus Torvalds Subject: [PATCH 4.20 04/65] zram: fix double free backing device Date: Fri, 11 Jan 2019 15:14:50 +0100 Message-Id: <20190111131056.679232043@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131055.331350141@linuxfoundation.org> References: <20190111131055.331350141@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Minchan Kim commit 5547932dc67a48713eece4fa4703bfdf0cfcb818 upstream. If blkdev_get fails, we shouldn't do blkdev_put. Otherwise, kernel emits below log. This patch fixes it. WARNING: CPU: 0 PID: 1893 at fs/block_dev.c:1828 blkdev_put+0x105/0x120 Modules linked in: CPU: 0 PID: 1893 Comm: swapoff Not tainted 4.19.0+ #453 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 RIP: 0010:blkdev_put+0x105/0x120 Call Trace: __x64_sys_swapoff+0x46d/0x490 do_syscall_64+0x5a/0x190 entry_SYSCALL_64_after_hwframe+0x49/0xbe irq event stamp: 4466 hardirqs last enabled at (4465): __free_pages_ok+0x1e3/0x490 hardirqs last disabled at (4466): trace_hardirqs_off_thunk+0x1a/0x1c softirqs last enabled at (3420): __do_softirq+0x333/0x446 softirqs last disabled at (3407): irq_exit+0xd1/0xe0 Link: http://lkml.kernel.org/r/20181127055429.251614-3-minchan@kernel.org Signed-off-by: Minchan Kim Reviewed-by: Sergey Senozhatsky Reviewed-by: Joey Pabalinas Cc: [4.14+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- drivers/block/zram/zram_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -382,8 +382,10 @@ static ssize_t backing_dev_store(struct bdev = bdgrab(I_BDEV(inode)); err = blkdev_get(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL, zram); - if (err < 0) + if (err < 0) { + bdev = NULL; goto out; + } nr_pages = i_size_read(inode) >> PAGE_SHIFT; bitmap_sz = BITS_TO_LONGS(nr_pages) * sizeof(long);