Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5576546iob; Mon, 9 May 2022 21:16:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEYNJMKvWS+N0PCDgM1RmBTd4+Oc/fGvbKxbaRXf+8yv29Ja/tsFLxnj3cmgDv3/kifMpa X-Received: by 2002:a63:6bc4:0:b0:3c1:e5d5:61d7 with SMTP id g187-20020a636bc4000000b003c1e5d561d7mr15247260pgc.418.1652156192127; Mon, 09 May 2022 21:16:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652156192; cv=none; d=google.com; s=arc-20160816; b=MPsWudhiacnVjKRwJ4EiBw8FeMFj1px4yrDr1ap+FrWZ4rLlmeaTcPxJB0WAgXceXm sjIk76Lk1tHmMKjtIwJINTr5Ja0BhGU+djy7WNqx1FvPwTS/4JPII2M8ZJO6GSF5qY/V zVbMMKcK7e8eCZTlqHrTtww4wFXNd0I9yM01MF59qwMFFi9uROc5E+4fsOU/dgqkBst4 NEVe6k+VMiKCfZhlB6fZA0MFwrc3PFuIxEe+9hV4Ua1m9kHMSljYzaX+SXTf0M9Q4IeY ozgWk4v6zmIiIHL0+HIDN9Ckf/48mO7urMX6CQQ12pLSHraadW8CldTGZK60rW2gNvjS 5ueg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=btuSt+eTiboN9EpYdhYjr//P8XlvonQ50rzV3e6NBaU=; b=Bj8eTc84ZRCqBxwoqbGF0RmN2U+wWASls2wWPWp5jIN79b1PAvle6HjVJ+dJoA8Kxk jMl8bW+W4eozUOF/4DYD7pA3eY+H6AFp/GIGKjkPNacYhpCZ3ti+LNtebi6S++yRUySE 79AwWRbSHhHFFXYwUkf/oY3u1NN9He+O1ODWwFfxJQjIDQSzbqpKKPT3PFwHUOE7LfU1 XbSTRaBW9fU7QTCdFH2iHRzWUeSNsi0HysJ/4aXGKXLpD1RuFYm69rdlW/1M6xOgACIp UiFGyGobMqBsO8jO4qka3koUJImASC+KzX/E6SAVjXCtK8blhWnHHHb9cETgphSGXIGG x2eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TO1hx16U; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n2-20020a17090a2bc200b001cd4990ce8esi1321600pje.121.2022.05.09.21.16.16; Mon, 09 May 2022 21:16:32 -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=@redhat.com header.s=mimecast20190719 header.b=TO1hx16U; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234880AbiEJCo4 (ORCPT + 99 others); Mon, 9 May 2022 22:44:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234866AbiEJCoz (ORCPT ); Mon, 9 May 2022 22:44:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 999679154C for ; Mon, 9 May 2022 19:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652150458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=btuSt+eTiboN9EpYdhYjr//P8XlvonQ50rzV3e6NBaU=; b=TO1hx16UrxNuTF9+7/yp8CLSgdweQ7od1U6ld1WcSQifyBN6pkzb+0CzjKXQDnyLQIHkQV GLWW/+hdzOXs1Vs+M0MvYWh1LQsG6h7/8cy/4a8npCwLqINVvqcVr13NttE7fOCJp3Tpd+ XZqqhXMnTvpKKv41fZw9xXyVohUVz9g= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-605-jXuMnlcDMfSuyUWjFhGkdw-1; Mon, 09 May 2022 22:40:57 -0400 X-MC-Unique: jXuMnlcDMfSuyUWjFhGkdw-1 Received: by mail-lj1-f198.google.com with SMTP id x4-20020a05651c104400b0024f253d777fso4684099ljm.16 for ; Mon, 09 May 2022 19:40:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=btuSt+eTiboN9EpYdhYjr//P8XlvonQ50rzV3e6NBaU=; b=uw7dDhx8KmzPv2+IgCtDJMha9nvAM76aEGJimrLX8+Ltqpz7ntj1/D+BLc4E8gjFdU GlEe+bvfK6Hr81tr1GdyZWVPmfPK13X+NoJrGNekoQ4F9VrtN6R4lUWcfjq1826x5Eff q84yAACKDcD3P1/t+F84Y+pdm2uePnQdc1do2+kAaGIGifFyQK2VUkRJjnXspLhqMyqf jR+2W6sJLFvsWY3U8r20bdlWEkRvcKpGGwiTQwvgd9lrzQQhAPkzgtELATcw7CRU875a 1xFFQXipORMoyaf2FsTyKwIANUKpW2ZzWVXNpbVfmk1KCrsqBhZBACRWQBwB8uaHi29Z 7HwA== X-Gm-Message-State: AOAM53006bARnKEaIsR9Nr1eqoqF75BQXi7hA3ULp7aXH4+BGuOTT4g4 BZveukXzJ3YSOD83iagpBhZpQpywRFjVl+gCxskPrHdaqnqXJopPCHlELKjJbT+324U70+xd+Ht AKB2DcReWFGgeXENM3NYRl20dGKFBroyKmYHoICkw X-Received: by 2002:a19:ca50:0:b0:471:f556:92b with SMTP id h16-20020a19ca50000000b00471f556092bmr14762567lfj.587.1652150455983; Mon, 09 May 2022 19:40:55 -0700 (PDT) X-Received: by 2002:a19:ca50:0:b0:471:f556:92b with SMTP id h16-20020a19ca50000000b00471f556092bmr14762559lfj.587.1652150455802; Mon, 09 May 2022 19:40:55 -0700 (PDT) MIME-Version: 1.0 References: <20220508163317.204673-1-elic@nvidia.com> <20220508163317.204673-2-elic@nvidia.com> In-Reply-To: <20220508163317.204673-2-elic@nvidia.com> From: Jason Wang Date: Tue, 10 May 2022 10:40:44 +0800 Message-ID: Subject: Re: [PATCH v4 1/3] vdpa: Fix error logic in vdpa_nl_cmd_dev_get_doit To: Eli Cohen Cc: mst , virtualization , linux-kernel , Si-Wei Liu Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Mon, May 9, 2022 at 12:33 AM Eli Cohen wrote: > > In vdpa_nl_cmd_dev_get_doit(), ff the call to genlmsg_reply() fails we I guess you mean "if" here? > must not call nlmsg_free() since this is done inside genlmsg_reply(). > > Fix it. > > Fixes: bc0d90ee021f ("vdpa: Enable user to query vdpa device info") > Signed-off-by: Eli Cohen Other than the above typo. Acked-by: Jason Wang > --- > drivers/vdpa/vdpa.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c > index 2b75c00b1005..fac89a0d8178 100644 > --- a/drivers/vdpa/vdpa.c > +++ b/drivers/vdpa/vdpa.c > @@ -756,14 +756,19 @@ static int vdpa_nl_cmd_dev_get_doit(struct sk_buff *skb, struct genl_info *info) > goto mdev_err; > } > err = vdpa_dev_fill(vdev, msg, info->snd_portid, info->snd_seq, 0, info->extack); > - if (!err) > - err = genlmsg_reply(msg, info); > + if (err) > + goto mdev_err; > + > + err = genlmsg_reply(msg, info); > + put_device(dev); > + mutex_unlock(&vdpa_dev_mutex); > + return err; > + > mdev_err: > put_device(dev); > err: > mutex_unlock(&vdpa_dev_mutex); > - if (err) > - nlmsg_free(msg); > + nlmsg_free(msg); > return err; > } > > -- > 2.35.1 >