From patchwork Mon Mar 27 17:54:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michal Luczaj X-Patchwork-Id: 13189789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C813C6FD1D for ; Mon, 27 Mar 2023 17:56:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232693AbjC0R4N (ORCPT ); Mon, 27 Mar 2023 13:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232694AbjC0Rzw (ORCPT ); Mon, 27 Mar 2023 13:55:52 -0400 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [IPv6:2a0c:5a00:149::26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66B28198B for ; Mon, 27 Mar 2023 10:55:24 -0700 (PDT) Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1pgr3x-00G2vH-1Z for kvm@vger.kernel.org; Mon, 27 Mar 2023 19:55:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rbox.co; s=selector2; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject :Cc:To:From; bh=KcWcEhbQnzaM+OWGrcO8TZoiwnEN030AVSvJxRyahQA=; b=RM4IXxkzaqpb7 yS9UjqEPHZ8KJPlTri7M1tdyU9LxlOEx9biLrOWqPXJHGlfd04eYj1WJwot7eE+kiVpb6Ip9LjlRz 8FEu722fZoX9XWzP6QvtA5Opsd05duH/9oD8KeLXyz7B7CC6uE1Er7VEThoTqAeQHxHhYdamaotFf NTjwHvxLscb3/+ymzeiF2CLbCRR9zYY2O8QrZ8PXR1ytEIrDy+OBC+q1FyMaWLAWc6FFwDMBDlZFU 4R+G4QWEejRY+vKMuILlogeQQpcwiu6k2qakeNfMUN/X8/pI9jGcYxP8CbnGhn51B7/po9kuXHtl0 N381ze1H8oRBJADaBKbag==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1pgr3w-00016n-Bz; Mon, 27 Mar 2023 19:55:20 +0200 Received: by submission03.runbox with esmtpsa [Authenticated ID (604044)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1pgr3u-0006eO-N1; Mon, 27 Mar 2023 19:55:18 +0200 From: Michal Luczaj To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, Michal Luczaj Subject: [PATCH] KVM: Don't kfree(NULL) on kzalloc() failure in kvm_assign_ioeventfd_idx() Date: Mon, 27 Mar 2023 19:54:57 +0200 Message-Id: <20230327175457.735903-1-mhal@rbox.co> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On kzalloc() failure, taking the `goto fail` path leads to kfree(NULL). Such no-op has no use. Move it out. Signed-off-by: Michal Luczaj Reviewed-by: Sean Christopherson Reviewed-by: Philippe Mathieu-Daudé --- virt/kvm/eventfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 2a3ed401ce46..385368e706e5 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -856,9 +856,9 @@ static int kvm_assign_ioeventfd_idx(struct kvm *kvm, unlock_fail: mutex_unlock(&kvm->slots_lock); + kfree(p); fail: - kfree(p); eventfd_ctx_put(eventfd); return ret;