From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752385AbdECM4h (ORCPT ); Wed, 3 May 2017 08:56:37 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38221 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752036AbdECM4W (ORCPT ); Wed, 3 May 2017 08:56:22 -0400 From: Gerald Schaefer To: Dan Williams , Jens Axboe Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Gerald Schaefer Subject: [PATCH] brd: fix uninitialized use of brd->dax_dev Date: Wed, 3 May 2017 14:56:02 +0200 X-Mailer: git-send-email 2.10.2 X-TM-AS-GCONF: 00 x-cbid: 17050312-0040-0000-0000-0000037D3432 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17050312-0041-0000-0000-000025360CD9 Message-Id: <20170503125602.26956-1-gerald.schaefer@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-05-03_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705030240 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 1647b9b9 "brd: add dax_operations support" introduced the allocation and freeing of a dax_device, but the allocated dax_device is not stored into the brd_device, so brd_del_one() will eventually operate on an uninitialized brd->dax_dev. Fix this by storing the allocated dax_device to brd->dax_dev. Signed-off-by: Gerald Schaefer --- drivers/block/brd.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 38f38df..57b574f 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -404,9 +404,7 @@ static struct brd_device *brd_alloc(int i) { struct brd_device *brd; struct gendisk *disk; -#ifdef CONFIG_BLK_DEV_RAM_DAX - struct dax_device *dax_dev; -#endif + brd = kzalloc(sizeof(*brd), GFP_KERNEL); if (!brd) goto out; @@ -443,8 +441,8 @@ static struct brd_device *brd_alloc(int i) #ifdef CONFIG_BLK_DEV_RAM_DAX queue_flag_set_unlocked(QUEUE_FLAG_DAX, brd->brd_queue); - dax_dev = alloc_dax(brd, disk->disk_name, &brd_dax_ops); - if (!dax_dev) + brd->dax_dev = alloc_dax(brd, disk->disk_name, &brd_dax_ops); + if (!brd->dax_dev) goto out_free_inode; #endif @@ -453,8 +451,8 @@ static struct brd_device *brd_alloc(int i) #ifdef CONFIG_BLK_DEV_RAM_DAX out_free_inode: - kill_dax(dax_dev); - put_dax(dax_dev); + kill_dax(brd->dax_dev); + put_dax(brd->dax_dev); #endif out_free_queue: blk_cleanup_queue(brd->brd_queue); -- 2.10.2