From patchwork Wed Nov 6 09:38:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ritesh Harjani X-Patchwork-Id: 1190192 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 477M0c3ffmz9sPn for ; Wed, 6 Nov 2019 20:38:24 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728742AbfKFJiX (ORCPT ); Wed, 6 Nov 2019 04:38:23 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:28998 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726143AbfKFJiW (ORCPT ); Wed, 6 Nov 2019 04:38:22 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id xA69baKg117189 for ; Wed, 6 Nov 2019 04:38:21 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2w3st7vj1y-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 06 Nov 2019 04:38:21 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Nov 2019 09:38:19 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 6 Nov 2019 09:38:16 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xA69cFp518546916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Nov 2019 09:38:15 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 78D2AAE055; Wed, 6 Nov 2019 09:38:15 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1804EAE051; Wed, 6 Nov 2019 09:38:14 +0000 (GMT) Received: from dhcp-9-199-158-77.in.ibm.com (unknown [9.199.158.77]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 6 Nov 2019 09:38:13 +0000 (GMT) From: Ritesh Harjani To: dan.carpenter@oracle.com, tytso@mit.edu, jack@suse.cz Cc: linux-ext4@vger.kernel.org, Ritesh Harjani Subject: [PATCH 1/1] ext4: Add error handling for io_end_vec struct allocation Date: Wed, 6 Nov 2019 15:08:09 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191106082505.GA31923@mwanda> References: <20191106082505.GA31923@mwanda> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19110609-0008-0000-0000-0000032C0349 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19110609-0009-0000-0000-00004A4B036C Message-Id: <20191106093809.10673-1-riteshh@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-11-06_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1911060099 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This patch adds the error handling in case of any memory allocation failure for io_end_vec. This was missing in original patch series which enables dioread_nolock for blocksize < pagesize. Fixes: c8cc88163f40 ("ext4: Add support for blocksize < pagesize in dioread_nolock") Reported-by: Dan Carpenter Signed-off-by: Ritesh Harjani --- fs/ext4/inode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 381813205f99..de70f19bfa7e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2240,6 +2240,10 @@ static int mpage_process_page(struct mpage_da_data *mpd, struct page *page, err = 0; if (!err && mpd->map.m_len && mpd->map.m_lblk > lblk) { io_end_vec = ext4_alloc_io_end_vec(io_end); + if (IS_ERR(io_end_vec)) { + err = PTR_ERR(io_end_vec); + goto out; + } io_end_vec->offset = mpd->map.m_lblk << blkbits; } *map_bh = true; @@ -2405,8 +2409,11 @@ static int mpage_map_and_submit_extent(handle_t *handle, loff_t disksize; int progress = 0; ext4_io_end_t *io_end = mpd->io_submit.io_end; - struct ext4_io_end_vec *io_end_vec = ext4_alloc_io_end_vec(io_end); + struct ext4_io_end_vec *io_end_vec; + io_end_vec = ext4_alloc_io_end_vec(io_end); + if (IS_ERR(io_end_vec)) + return PTR_ERR(io_end_vec); io_end_vec->offset = ((loff_t)map->m_lblk) << inode->i_blkbits; do { err = mpage_map_one_extent(handle, mpd);