From patchwork Thu Jun 16 09:47:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9180347 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E55C660573 for ; Thu, 16 Jun 2016 09:51:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D83902831C for ; Thu, 16 Jun 2016 09:51:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD19028354; Thu, 16 Jun 2016 09:51:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D74E22831C for ; Thu, 16 Jun 2016 09:51:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u5G9mUuZ023262; Thu, 16 Jun 2016 05:48:30 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u5G9m0Y5005829 for ; Thu, 16 Jun 2016 05:48:00 -0400 Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5G9m0RW002266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 16 Jun 2016 05:48:00 -0400 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE4183DD47; Thu, 16 Jun 2016 09:47:58 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 52182ADE2; Thu, 16 Jun 2016 09:47:53 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Thu, 16 Jun 2016 11:47:27 +0200 Message-Id: <1466070465-1021-22-git-send-email-hare@suse.de> In-Reply-To: <1466070465-1021-1-git-send-email-hare@suse.de> References: <1466070465-1021-1-git-send-email-hare@suse.de> X-Greylist: Sender IP whitelisted by DNSRBL, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 16 Jun 2016 09:47:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 16 Jun 2016 09:47:59 +0000 (UTC) for IP:'195.135.220.15' DOMAIN:'mx2.suse.de' HELO:'mx2.suse.de' FROM:'hare@suse.de' RCPT:'' X-RedHat-Spam-Score: -3.327 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 195.135.220.15 mx2.suse.de 195.135.220.15 mx2.suse.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-loop: dm-devel@redhat.com Cc: Hannes Reinecke , dm-devel@redhat.com Subject: [dm-devel] [PATCH 21/39] libmpathpersist: Pass sensebuffer as pointer X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP It makes no sense to pass the entire sense buffer as a value, we should rather pass the pointer to avoid exploding the stack. Found by coverity. Signed-off-by: Hannes Reinecke --- libmpathpersist/mpath_pr_ioctl.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/libmpathpersist/mpath_pr_ioctl.c b/libmpathpersist/mpath_pr_ioctl.c index c85fd10..c37c1e4 100644 --- a/libmpathpersist/mpath_pr_ioctl.c +++ b/libmpathpersist/mpath_pr_ioctl.c @@ -24,7 +24,8 @@ int prin_do_scsi_ioctl(char * dev, int rq_servact, struct prin_resp *resp, int noisy); void mpath_format_readkeys(struct prin_resp *pr_buff, int len , int noisy); void mpath_format_readfullstatus(struct prin_resp *pr_buff, int len, int noisy); -int mpath_translate_response (char * dev, struct sg_io_hdr io_hdr, SenseData_t Sensedata, int noisy); +int mpath_translate_response (char * dev, struct sg_io_hdr io_hdr, + SenseData_t *Sensedata, int noisy); void dumpHex(const char* str, int len, int no_ascii); int prout_do_scsi_ioctl( char * dev, int rq_servact, int rq_scope, unsigned int rq_type, struct prout_param_descriptor *paramp, int noisy); @@ -113,7 +114,7 @@ retry : condlog(2, "%s: Duration=%u (ms)", dev, io_hdr.duration); - status = mpath_translate_response(dev, io_hdr, Sensedata, noisy); + status = mpath_translate_response(dev, io_hdr, &Sensedata, noisy); condlog(3, "%s: status = %d", dev, status); if (status == MPATH_PR_SENSE_UNIT_ATTENTION && (retry > 0)) @@ -353,7 +354,7 @@ retry : condlog(2, "%s: duration = %u (ms)", dev, io_hdr.duration); condlog(2, "%s: persistent reservation in: requested %d bytes but got %d bytes)", dev, mx_resp_len, got); - status = mpath_translate_response(dev, io_hdr, Sensedata, noisy); + status = mpath_translate_response(dev, io_hdr, &Sensedata, noisy); if (status == MPATH_PR_SENSE_UNIT_ATTENTION && (retry > 0)) { @@ -398,26 +399,25 @@ out: return status; } -int mpath_translate_response (char * dev, struct sg_io_hdr io_hdr, SenseData_t Sensedata, int noisy) +int mpath_translate_response (char * dev, struct sg_io_hdr io_hdr, + SenseData_t *Sensedata, int noisy) { - condlog(3, "%s: status driver:%02x host:%02x scsi:%02x", dev, - io_hdr.driver_status, io_hdr.host_status ,io_hdr.status); + condlog(3, "%s: status driver:%02x host:%02x scsi:%02x", dev, + io_hdr.driver_status, io_hdr.host_status, io_hdr.status); io_hdr.status &= 0x7e; - if ((0 == io_hdr.status) && (0 == io_hdr.host_status) && - (0 == io_hdr.driver_status)) - { + if ((0 == io_hdr.status) && + (0 == io_hdr.host_status) && + (0 == io_hdr.driver_status)) return MPATH_PR_SUCCESS; - } - switch(io_hdr.status) - { + switch(io_hdr.status) { case SAM_STAT_GOOD: break; case SAM_STAT_CHECK_CONDITION: - condlog(2, "%s: Sense_Key=%02x, ASC=%02x ASCQ=%02x", dev, - Sensedata.Sense_Key, Sensedata.ASC, Sensedata.ASCQ); - switch(Sensedata.Sense_Key) - { + condlog(2, "%s: Sense_Key=%02x, ASC=%02x ASCQ=%02x", + dev, Sensedata->Sense_Key, + Sensedata->ASC, Sensedata->ASCQ); + switch(Sensedata->Sense_Key) { case NO_SENSE: return MPATH_PR_NO_SENSE; case RECOVERED_ERROR: @@ -450,8 +450,7 @@ int mpath_translate_response (char * dev, struct sg_io_hdr io_hdr, SenseData_t S return MPATH_PR_OTHER; } - switch(io_hdr.host_status) - { + switch(io_hdr.host_status) { case DID_OK : break; default :