Received: by 10.213.65.68 with SMTP id h4csp37033imn; Mon, 19 Mar 2018 18:45:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELtJx0ve+yIhUqR7LqyuR1O80g/3i/LGedDRewDVJ+cBg753HtpJy9qpf/z2k+f0H1XfX97x X-Received: by 2002:a17:902:6085:: with SMTP id s5-v6mr11445926plj.307.1521510303180; Mon, 19 Mar 2018 18:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510303; cv=none; d=google.com; s=arc-20160816; b=X7TO4kjrMQeAE6Im0kwB+hgg1/7rgdLcLXbOOKStJp4VkGjeYJz64l6Jvr5+gXU6ty qBFU8G+1OgjFRAXYqXIrsrNpCoF3xJ0XkA1HX43GYI9UFOlizlD7ucxpQVyphUaczyK0 NAv+U0KZvtVqlp9xiKepwk1Q8ikmtBWPytYZHfyWPZdh9WRmPZyF2Mkg8pqviYAOzI3c k+0zJP5+xq3hG1nK72xdnZVUfUI4EE0rA2nmO7oFKIZcFpXBJqfSnEsPkFSfD7b5HKpc FYZ0FLJtqAFgdDE2IsTsroKAnAkLf/IlVJpyoKwLEwcEVinrsWJGX9bav6TKRaHZdcGt 4TEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=sbgtRBfCz4yyt/cKj5oeH0L6xLE3q636BqnYMRSYetE=; b=ctcofkT7TUSt2gd0IByZXjLLz7U07m5cLvtFnxYmku5IWG2TNcwd6Mwf5FtyK1oUNV phIsVxH0Db72klcFC5e74rrn6lBSk7a3kQibKLfMkHbgstXrBjdk5atz57NuZIh1n55+ JcQPETMHG/7RFMKRx+MOrkP5J/jdK/ryQAflD4vvstpKM22olNY7ZUKCBGkQDOOguVNu zEmAP/LltalOG/Bnveg0H6YJwfT4P/YVrCxcGVBmO5MG8nXToz0YipEyTsKZIwBZ22Fx 8RJA7NFuuUgHjVlhJ6MaZqYgjaYWI4aWiAItLeXH2iAI2/Be2CHymGclFhwI43CWS8JJ UbwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3-v6si536333plb.480.2018.03.19.18.44.49; Mon, 19 Mar 2018 18:45:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970798AbeCSTHI (ORCPT + 99 others); Mon, 19 Mar 2018 15:07:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52206 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970130AbeCSS21 (ORCPT ); Mon, 19 Mar 2018 14:28:27 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9DDF5E08; Mon, 19 Mar 2018 18:28:26 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Colin Ian King , Dan Carpenter , Douglas Gilbert , "Martin K. Petersen" Subject: [PATCH 4.9 234/241] scsi: sg: fix static checker warning in sg_is_valid_dxfer Date: Mon, 19 Mar 2018 19:08:19 +0100 Message-Id: <20180319180800.864703866@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johannes Thumshirn commit 14074aba4bcda3764c9a702b276308b89901d5b6 upstream. dxfer_len is an unsigned int and we always assign a value > 0 to it, so it doesn't make any sense to check if it is < 0. We can't really check dxferp as well as we have both NULL and not NULL cases in the possible call paths. So just return true for SG_DXFER_FROM_DEV transfer in sg_is_valid_dxfer(). Signed-off-by: Johannes Thumshirn Reported-by: Colin Ian King Reported-by: Dan Carpenter Cc: Douglas Gilbert Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/sg.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -759,8 +759,11 @@ static bool sg_is_valid_dxfer(sg_io_hdr_ return false; return true; case SG_DXFER_FROM_DEV: - if (hp->dxfer_len < 0) - return false; + /* + * for SG_DXFER_FROM_DEV we always set dxfer_len to > 0. dxferp + * can either be NULL or != NULL so there's no point in checking + * it either. So just return true. + */ return true; case SG_DXFER_TO_DEV: case SG_DXFER_TO_FROM_DEV: