Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1732439pxu; Thu, 8 Oct 2020 20:47:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNDQX7Ok0b0VbIDfzyw+cfFy2vp97yeCmcMCHLirwIkNNB0Zesgwqz5qCZosMsu4P7rrm1 X-Received: by 2002:aa7:c659:: with SMTP id z25mr12296814edr.219.1602215251110; Thu, 08 Oct 2020 20:47:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602215251; cv=none; d=google.com; s=arc-20160816; b=vtg/r5SnV4P9eob85wnQX052L+3qwD0pV1aZBR1bbgfOGI7W3YxQhg/lezDbDwIUJB 68NLEN/YFPui4Vtzbu+5/0N/NDzzJjEyi82lGcjgCSDJnGl3lOEBYrtMu+fKE+sVnWhc wRAIDFA4Wp3YOUR32e/DllqVE1u/k+Bv+C7O7b75vdNlNQRNR/Kbjlz1L8euLI6aWOSj SLcwc4e+Gg+n5iRSewQjC8LARihu/dSMeQCIn1RFwUzEfLPGEcW61K4Nh+27OtEL7xpN MZHm3942Jvj7EPVeMucOT08GulLsXSRBYno5t8e4Nn5O0D0NTmWNWrJgOSNSBr232sZ3 XS+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=xVtaazHLap0AOGbhNnd3svkYUCPJJww/W0XS3nSiO+8=; b=rIdryTIIDtmQLwQMC/V29L9MIHF3pLrKKoqFyWaPzHvlUFFzr1SqxjMD+i5j8TqSo0 nUWppTxn8FkC8oyR+C4avz5evKD4UmZ+/RT4JhYDYWDg2A0XKCTwBuXxHlZKtbs07xuw r0nNK+/qQL+u5JRpWksnRZPGdX2uy9zSX8V6mKOjl1gBC1jw+1SV4FUCz4SayGBqxk0L 6gmULRNJQiZbxeL97I88LTzUEtmGGTAXTs0c5fBZnn17Gx7INduI3ShkZv4T9vya9lhf J31qWBy2YJW6MRe+RD3KAwyZYcPsn2GuOyvvJZ8Jsrm4rTEwNtk5p1FHjf2QBfkCBb88 s9+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=nbww3YdN; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e12si5306415ejd.673.2020.10.08.20.47.08; Thu, 08 Oct 2020 20:47:31 -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=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=nbww3YdN; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729017AbgJIBJr (ORCPT + 99 others); Thu, 8 Oct 2020 21:09:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728922AbgJIBJq (ORCPT ); Thu, 8 Oct 2020 21:09:46 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ECC2C0613D2 for ; Thu, 8 Oct 2020 18:09:45 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id 144so5442765pfb.4 for ; Thu, 08 Oct 2020 18:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=xVtaazHLap0AOGbhNnd3svkYUCPJJww/W0XS3nSiO+8=; b=nbww3YdNEubpRBuP77GrOtqtpaNcCVF1sBRT/DemJ9upzP2NEPwxnfX4P7aq51Yckv PpvkynNQZetIrV2l7mvwlppEm5vcY7BOFODRFm3xMAuHE7aE7D+VAyupKzEaIdGvkKVe VbuZC4z3kLeu9S71zb7RvUtcJwo1qLl90Br5t7hjRW8rct62xrLiHFthWhcqW/k/3Hf7 DrLbz2jpVbyUN3RgDBA/0PN3jefNXg/qmLMEPg9LXTaGQssns/Q7xOG0nGP5ZHJfi9W9 7S6v4zys7kI9mekUbJyhzXR5NfAC8lzEM2S+DAvDKOPoSHwxDsZpqeeQQiLvhsuG9siX Auwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xVtaazHLap0AOGbhNnd3svkYUCPJJww/W0XS3nSiO+8=; b=IAy77ic0Yf23lW+Ly1AGy7mBQ9gFGlltlsdEXSCYWxMQkUZpNkElRhn1TP1+nXdRZv lZDJgO6GwmVf6R+YnsDsWdIQkwZApCnV/P9W/DYYQMtj2dsVNpaoWSuD8FPZCozBOqFb y2eZPjAgzrMssE3o2nSrdMTjXwroAdQMOvOQeXhm6FFMPTHoblx1jdy8KDTjaScqxxlw rJ1xHLyECVcRu3OZ2QlvE++pEekeSecQxCgZbfl3qzwJ62lbogHOxuXUHXp2TC0WYit1 8kGm6JVLVyw+yoXKsu2pHIzP7P1OsiwFp5uI5ibVs7uXkC963Y0xHKlh6+s0dbfr9H2+ lpEA== X-Gm-Message-State: AOAM5336rffrJCIuQzDAf25I/kIbAJZ5C1mxQ4AcxCALHMaSgHT8wUZE VjMKoXYzlR8EiGhpD0zzaqiY2TWrpa6dRg63 X-Received: by 2002:a17:90a:3804:: with SMTP id w4mr1710860pjb.171.1602205784152; Thu, 08 Oct 2020 18:09:44 -0700 (PDT) Received: from [192.168.1.134] ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id l82sm3984061pfd.102.2020.10.08.18.09.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Oct 2020 18:09:43 -0700 (PDT) Subject: Re: io_uring: process task work in io_uring_register() To: Colin Ian King Cc: Alexander Viro , linux-fsdevel , io-uring@vger.kernel.org, "linux-kernel@vger.kernel.org" References: From: Jens Axboe Message-ID: <781195af-9d58-202f-0451-b36c1705fdc1@kernel.dk> Date: Thu, 8 Oct 2020 19:09:41 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/8/20 12:23 PM, Colin Ian King wrote: > Hi, > > Static analysis with Coverity has detected a "dead-code" issue with the > following commit: > > commit af9c1a44f8dee7a958e07977f24ba40e3c770987 > Author: Jens Axboe > Date: Thu Sep 24 13:32:18 2020 -0600 > > io_uring: process task work in io_uring_register() > > The analysis is as follows: > > 9513 do { > 9514 ret = > wait_for_completion_interruptible(&ctx->ref_comp); > > cond_const: Condition ret, taking false branch. Now the value of ret is > equal to 0. > > 9515 if (!ret) > 9516 break; > 9517 if (io_run_task_work_sig() > 0) > 9518 continue; > 9519 } while (1); > 9520 > 9521 mutex_lock(&ctx->uring_lock); > 9522 > > const: At condition ret, the value of ret must be equal to 0. > dead_error_condition: The condition ret cannot be true. Thanks, yeah that condition is reversed, should be: diff --git a/fs/io_uring.c b/fs/io_uring.c index 4df5b14c2e56..80a0aa33db49 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -9511,8 +9511,8 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, ret = wait_for_completion_interruptible(&ctx->ref_comp); if (!ret) break; - if (io_run_task_work_sig() > 0) - continue; + if (io_run_task_work_sig() <= 0) + break; } while (1); mutex_lock(&ctx->uring_lock); -- Jens Axboe