Received: by 10.213.65.68 with SMTP id h4csp36038imn; Mon, 19 Mar 2018 18:42:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELsHN3orZA2GKRf7ggHLfGs01PJj9187IkUO7mWHjbq9hQW8KqV3O0pFSzzffQutcdzxQhWv X-Received: by 10.101.83.13 with SMTP id m13mr10943638pgq.248.1521510179284; Mon, 19 Mar 2018 18:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510179; cv=none; d=google.com; s=arc-20160816; b=fHKaJtr9UXVMmBaDCVNJ9CfAmNrK+ZYrvql2N1dR5xEyCWYspif4XHOuqapfF5BJUT 6Q+n+pJwc+OSCC0AZrowGuip/Q64L+ExJGYUju2d2/ziOBjign2NXHfF6PfMNdubrwqd 5v2WMW83nEi0p+TM4mrjG4/yiVTlHHvtZAWlkJx8x23pJVYSau6+VciRp1y881ImfNHz rmxHRy/2nf8jWt0E/LbX9tAq3QtAU0V6V183UUr9sLcmTy2wHfT/YgTSmU0M1dCrjZ+D z+Pc9lhJGhEO+EXKtNXOuIAUG/CxjC5LKJdRXatiiwtzE8ZSE8SV+SIKnW+YtMv8DB0H HjoQ== 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=yqh5vJIL7YBC6X0+3cHEM8QHMgKyP0RmDyyGJBsUWBI=; b=AzvLymq+ZkcgdaBuyptIsThPo6OsL+w2yzcb9f7xU9XumXPn4V00XsIqzcD6Tk2+H9 30DCyC0lScB4u6Ae9h/uQaSPUNG4wOmNSy1mTbKB3T9vl3rBK8+g86RDUKBhOXsfWJ2H n7zpzmuActQHjzhWFCvHzVLNrNC5nfe98x8i7lV3psTKscbyhhVhMq0HXZTs1FxAuRNq 70ivaAunWShBkLpzqSTpwvke5IL3FEQKe7Aa8ovyLH6djAG9WGp2qV6XGbFmaTso4GGG EoKy2GNwAzcAQVIpzelTUkI0QgB9Auc5Ei+c41YBDRPPu6qKP2yDKNHO84k5ZYZKHmZw yXNQ== 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 l69si438803pfk.180.2018.03.19.18.42.45; Mon, 19 Mar 2018 18:42:59 -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 S969169AbeCSSRi (ORCPT + 99 others); Mon, 19 Mar 2018 14:17:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45518 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969139AbeCSSRY (ORCPT ); Mon, 19 Mar 2018 14:17:24 -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 D96151229; Mon, 19 Mar 2018 18:17:23 +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.4 127/134] scsi: sg: fix static checker warning in sg_is_valid_dxfer Date: Mon, 19 Mar 2018 19:06:50 +0100 Message-Id: <20180319171907.610726468@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@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.4-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 @@ -770,8 +770,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: