Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp450934imi; Thu, 21 Jul 2022 04:32:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tJ4Zai8Ox8MaWDdZRlzXEWte29agB+1jeu8a+TMjx7WgyMbLpqM9SFs1Ssy0GextMTQG+Y X-Received: by 2002:a17:902:988b:b0:16b:fae3:fcd5 with SMTP id s11-20020a170902988b00b0016bfae3fcd5mr44330860plp.109.1658403163344; Thu, 21 Jul 2022 04:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658403163; cv=none; d=google.com; s=arc-20160816; b=hgUMrawoe+17JAI8L30H76u9ial1lqmLgO+FxiH7WGmQLziaVgKFTdY4D9LCoX4pX3 rlhbY4fnSFpF1tKTjFQ2MeFuI+ufXzLImR5p6OQ5BAjznmAJBhotG6IREPdLRMWPC04w RvCZnyVYNhilxzjo3+VeEbM6kKr5kYBkZakCZwK54JqkHH20Td6evg58nngU6ZW4KOZC kQAeKQavWNcW19K7i3djE6DaHnEGAKPcj4DDfDrOnsFlpQITDqv4prGbf1ErGTBJEEJ0 lChhPahVSDy4aoUErO87jdmUe3Bd+sdhTJYM3jjeW0V34m8Lo8XSsujWruJ2zdcLkfKR uXbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=whhVqzSY/LO0DewExHF2H+9BIsdCKVF/W1wqXDtU4vs=; b=n3UDJfGHdiv4mHTH1sY/v5S1V2eviLLh7fe3r0DdzOl2lEXn3CTpM14eeIBdEuSU/y y0IXTek2DikNTrxVhvSxRpI7Sz4WPX2EbstcuVGNZjJ/mdiA98HuMMUPfVrOYULADKl3 edoVmCOxfqC1YyAdudTFlE8VyAHbpfolZExQ2mPr9oZblpQX8s4OmQnjzEZ1kAtTDG55 DghwmCsZa9Fe1WPCoQ9iE4XxoddanoqxrXuvscLRhF/M/JtSAgkpbgKjRGBdBLx34gYC gWEqksp807TidpbpaVCcDmF8GtlnpA+1lIrvzTnkQdKcZHrZr0LuzKAV7PKqp74gX9Us jbTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=aOrzG39w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w62-20020a626241000000b005253895c9d6si2046175pfb.226.2022.07.21.04.32.28; Thu, 21 Jul 2022 04:32:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=aOrzG39w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232845AbiGULB4 (ORCPT + 99 others); Thu, 21 Jul 2022 07:01:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbiGULBy (ORCPT ); Thu, 21 Jul 2022 07:01:54 -0400 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0700F7BE23 for ; Thu, 21 Jul 2022 04:01:53 -0700 (PDT) Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26KNbG71001149 for ; Thu, 21 Jul 2022 04:01:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=facebook; bh=whhVqzSY/LO0DewExHF2H+9BIsdCKVF/W1wqXDtU4vs=; b=aOrzG39w4NaSTRfYdS5WVdJ58/ibpbAC10EsBdP7vKiNUo3KZgm4uyqWGDD+YQoXEy6E MQLNJ71I8/UUnWl+JNIxr0HGwmqybXX3mg1J2GzdWSd7g9S8gGS9Aazaa07fPG97STSh n9untC5VdaxOZ1z4FAKRVi2N4tEwbNaCQ/8= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3hej1vpnxk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 21 Jul 2022 04:01:53 -0700 Received: from twshared5640.09.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 21 Jul 2022 04:01:51 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 6E24D3572D41; Thu, 21 Jul 2022 04:01:37 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov , CC: , , Dylan Yudaken , Dipanjan Das Subject: [PATCH] io_uring: fix free of unallocated buffer list Date: Thu, 21 Jul 2022 04:01:15 -0700 Message-ID: <20220721110115.3964104-1-dylany@fb.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: Dufsl5ryEtX99BqJ7d0r2e9kha7yFNAA X-Proofpoint-ORIG-GUID: Dufsl5ryEtX99BqJ7d0r2e9kha7yFNAA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_14,2022-07-20_01,2022-06-22_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org in the error path of io_register_pbuf_ring, only free bl if it was allocated. Reported-by: Dipanjan Das Fixes: c7fb19428d67 ("io_uring: add support for ring mapped supplied buff= ers") Signed-off-by: Dylan Yudaken --- fs/io_uring.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index a01ea49f3017..2b7bb62c7805 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -12931,7 +12931,7 @@ static int io_register_pbuf_ring(struct io_ring_c= tx *ctx, void __user *arg) { struct io_uring_buf_ring *br; struct io_uring_buf_reg reg; - struct io_buffer_list *bl; + struct io_buffer_list *bl, *free_bl =3D NULL; struct page **pages; int nr_pages; =20 @@ -12963,7 +12963,7 @@ static int io_register_pbuf_ring(struct io_ring_c= tx *ctx, void __user *arg) if (bl->buf_nr_pages || !list_empty(&bl->buf_list)) return -EEXIST; } else { - bl =3D kzalloc(sizeof(*bl), GFP_KERNEL); + free_bl =3D bl =3D kzalloc(sizeof(*bl), GFP_KERNEL); if (!bl) return -ENOMEM; } @@ -12972,7 +12972,7 @@ static int io_register_pbuf_ring(struct io_ring_c= tx *ctx, void __user *arg) struct_size(br, bufs, reg.ring_entries), &nr_pages); if (IS_ERR(pages)) { - kfree(bl); + kfree(free_bl); return PTR_ERR(pages); } =20 base-commit: ff6992735ade75aae3e35d16b17da1008d753d28 --=20 2.30.2