Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2883878pxa; Mon, 17 Aug 2020 23:58:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj7RxNZDnLVPFZdEyi9yLR+Wp2p8AOsK0hV+2BbDLSPNFqqcEgiaF6zpdAIaIqZmqPXJwH X-Received: by 2002:a05:6402:b99:: with SMTP id cf25mr17803493edb.340.1597733928428; Mon, 17 Aug 2020 23:58:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597733928; cv=none; d=google.com; s=arc-20160816; b=DcGZcuEnG5QeoKNZABHmucTqyYM03hKBhHfMpZ1j2FAIuL+VsqRMZ2UTYcbckr9IuO m85kTff6jXUZz1Sc2Z+XNTR+wL3wFbdoY5yvEX9HPqPCLLk1mzudgh5fd80G8HmlAx5z FQIqhtKK14OT4IrdQumM1KQre7WeLb81nZCHQ2AYmSENDeSpqCJBQTj2KOCpXeDeHR2G 6EC6YWidiF5vgXx60xs7s2w3xu6rfdv+2vNoNeWmpKBW7Iny4fIvOjpafwta+ceL1CNJ 9v4NEPnqMH55+TR1XIMmG/wbROMpFtsxU22VpyQNtrs0Rwbtb6y/Gq6/YzDfNs0k16eY LuHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=YVVIR500ClTyfmtyOwulLE+BvxQ0gs3eNmZQyHQPmgM=; b=qM3lXepPW0SXWP8OyDRe/eQRgArbHzm+Pay25PXjcYsUaG8J/0vctrMRNYaQx59cCA 85XAsk4/uU8c7qtiwVXge98jsNmU2deh9YQUVTKpuCJSqVsHkxQjFQxpiUQt0MVmP1no 71gXHXFBrqCxuHxQXgBgvIyiZyliD8LQbFdRtlSjJ47WKEs+6+VL3QB3o93K3sYySDVj tLBMxZhEdIINAI/jWDzM6y4nIFfjgjMUPGBkz0fULuMFG1EzTcqTiuc+KEVMoq1Jp3r4 Nlir0a7PrUflaVnpYnE+O0Vn5OiKdZrg8rEWCpy9f1VNoK+esIaXVnh+6FmSmdIWUZ3V VRig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloud.ionos.com header.s=google header.b=eJmbX1SW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ionos.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d10si12572003ejt.153.2020.08.17.23.58.25; Mon, 17 Aug 2020 23:58:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cloud.ionos.com header.s=google header.b=eJmbX1SW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ionos.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726514AbgHRGzn (ORCPT + 99 others); Tue, 18 Aug 2020 02:55:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbgHRGzn (ORCPT ); Tue, 18 Aug 2020 02:55:43 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2292C061342 for ; Mon, 17 Aug 2020 23:55:40 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id o18so20755367eje.7 for ; Mon, 17 Aug 2020 23:55:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YVVIR500ClTyfmtyOwulLE+BvxQ0gs3eNmZQyHQPmgM=; b=eJmbX1SWXaHlLz2f3BaAUUy7YdEU6kWkKuybjHFQ6gUZQpe/FwnP8wZnp+eEOeT2vI c86cRd+m4uSGPdTU9oC+0To3tpcbIyMQFeMuPAWZialvTXYdyGZEGfC0Kwdf3ZFViWqD X/UeZvVRDehlQuQdxP/dj9oxpJg0rHPpRBgmvmZi9Eu41pRsHXR3OzSvvrOeGxzuogkS 0gT/8fIt+TpaMbDH1fjYUEiCRUwqd/gDH5MXk9KrgvioyMg4fcPDV5jxBEe5azhq3pE/ 2Ir054g8ZeCUPhWmfqNWBNZCBFL0Yo7SZhqHVTQtaM3fRgwvY803RdlVcKnBNv12XvCs 8ouQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YVVIR500ClTyfmtyOwulLE+BvxQ0gs3eNmZQyHQPmgM=; b=Llb4EJPkZMQjgqZizHyD2idi7ndtXVD5GwMWv+3IbyqUe+rmfUfYa6ZU610dJaUEaV +dkfMGg9PgyQjzLbAFSaBVWXtPhg4z3Iz0lBoaIESCmCPvaeyhgGMszZlXsFE+QhhoSj Ar6pR4xx2G5KsSX5bQgyn68b5V49Hb7mmE2GcqwHdh17JUbs4/cUtH/8Hu2RcTFCCEfo 0cG/M862nLgsNk1QbIT60Qd4GjSVA1RD27zDdZRdUO/B6FVLL85DqpzPEYS+qkhIgpzA lfj7JKLpirVOoumJ+wsOdvL0fUZ9Kqrq759MmNYQYw5OLT6ODWmx7TaevK9COuDasolQ U0RA== X-Gm-Message-State: AOAM533W+zPwrO9B6IvwLd9w+1OQBZKDt8YSul4J1yTgIE0L3tm2wlwd bHE2PTT1yN6ZVVpIz/fNaVb0U7ELY6tW5VfLWiKnZ2w3yck= X-Received: by 2002:a17:906:a116:: with SMTP id t22mr19212136ejy.353.1597733739373; Mon, 17 Aug 2020 23:55:39 -0700 (PDT) MIME-Version: 1.0 References: <20200818064924.3984068-1-natechancellor@gmail.com> In-Reply-To: <20200818064924.3984068-1-natechancellor@gmail.com> From: Jinpu Wang Date: Tue, 18 Aug 2020 08:55:28 +0200 Message-ID: Subject: Re: [PATCH] block/rnbd: Ensure err is always initialized in process_rdma To: Nathan Chancellor Cc: Danil Kipnis , Jens Axboe , Guoqing Jiang , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Brooke Basile Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 18, 2020 at 8:50 AM Nathan Chancellor wrote: > > Clang warns: > > drivers/block/rnbd/rnbd-srv.c:150:6: warning: variable 'err' is used > uninitialized whenever 'if' condition is true > [-Wsometimes-uninitialized] > if (IS_ERR(bio)) { > ^~~~~~~~~~~ > drivers/block/rnbd/rnbd-srv.c:177:9: note: uninitialized use occurs here > return err; > ^~~ > drivers/block/rnbd/rnbd-srv.c:150:2: note: remove the 'if' if its > condition is always false > if (IS_ERR(bio)) { > ^~~~~~~~~~~~~~~~~~ > drivers/block/rnbd/rnbd-srv.c:126:9: note: initialize the variable 'err' > to silence this warning > int err; > ^ > = 0 > 1 warning generated. > > err is indeed uninitialized when this statement is taken. Ensure that it > is assigned the error value of bio before jumping to the error handling > label. > > Fixes: 735d77d4fd28 ("rnbd: remove rnbd_dev_submit_io") > Link: https://github.com/ClangBuiltLinux/linux/issues/1134 > Reported-by: Brooke Basile > Signed-off-by: Nathan Chancellor Thanks! Acked-by: Jack Wang > --- > drivers/block/rnbd/rnbd-srv.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c > index 0fb94843a495..1b71cb2a885d 100644 > --- a/drivers/block/rnbd/rnbd-srv.c > +++ b/drivers/block/rnbd/rnbd-srv.c > @@ -148,7 +148,8 @@ static int process_rdma(struct rtrs_srv *sess, > /* Generate bio with pages pointing to the rdma buffer */ > bio = rnbd_bio_map_kern(data, sess_dev->rnbd_dev->ibd_bio_set, datalen, GFP_KERNEL); > if (IS_ERR(bio)) { > - rnbd_srv_err(sess_dev, "Failed to generate bio, err: %ld\n", PTR_ERR(bio)); > + err = PTR_ERR(bio); > + rnbd_srv_err(sess_dev, "Failed to generate bio, err: %ld\n", err); > goto sess_dev_put; > } > > -- > 2.28.0 >