public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <jbottomley@parallels.com>
To: "thenzl@redhat.com" <thenzl@redhat.com>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"hch@infradead.org" <hch@infradead.org>,
	"hare@suse.de" <hare@suse.de>
Subject: Re: [PATCH] aic94xx: Fixup compilation warning
Date: Mon, 24 Nov 2014 16:10:02 +0000	[thread overview]
Message-ID: <1416845409.2194.7.camel@parallels.com> (raw)
In-Reply-To: <547356F6.3070404@redhat.com>

On Mon, 2014-11-24 at 17:04 +0100, Tomas Henzl wrote:
> On 11/24/2014 02:40 PM, Christoph Hellwig wrote:
> > Can someone review this trivial patch for me?  Thanks!
> >
> The compiler complains because when asd_find_flash_de fails, the offs is not initialized.
> When that happens this code is invoked :
>         if (err) {
>                 ASD_DPRINTK("couldn't find CTRL-A user settings section\n");
>                 ASD_DPRINTK("Creating default CTRL-A user settings section\n");
> 
>                 dflt_ps.id0 = 'h';
>                 dflt_ps.num_phys = 8;
>                 for (i =0; i < ASD_MAX_PHYS; i++) {
>                         memcpy(dflt_ps.phy_ent[i].sas_addr,
>                                asd_ha->hw_prof.sas_addr, SAS_ADDR_SIZE);
>                         dflt_ps.phy_ent[i].sas_link_rates = 0x98;
>                         dflt_ps.phy_ent[i].flags = 0x0;
>                         dflt_ps.phy_ent[i].sata_link_rates = 0x0;
>                 }
> 
>                 size = sizeof(struct asd_ctrla_phy_settings);
>                 ps = &dflt_ps;
> the dflt_ps is initialized and the address assigned to 'ps', but none of them is used later
>  }
> 
>         if (size == 0)
>                 goto out;
> 
>         err = -ENOMEM;
>         el = kmalloc(size, GFP_KERNEL);
>         if (!el) {
>                 ASD_DPRINTK("no mem for ctrla user settings section\n");
>                 goto out;
>         }
> 
>         err = asd_read_flash_seg(asd_ha, (void *)el, offs, size);
>         if (err) {
>                 ASD_DPRINTK("couldn't read ctrla phy settings section\n");
>                 goto out2;
>         }
> 
>         err = -ENOENT;
>         ps = asd_find_ll_by_id(el, 'h', 0xFF);
> here^ a new value is assigned to 'ps'
> 
> 
> I have no idea what was intended in the originally so - it looks likely, but how do we know that
> the '0' is a correct value for offs?

Yes, it seems to be the default from the hw ... if you don't have any
nvram then the phy setting are up first.

> Probably the error path is never used, this patch should fix the gcc warning too -
> @@ -990,20 +990,7 @@ static int asd_process_ctrl_a_user(struct asd_ha_struct *asd_ha,
>  	err = asd_find_flash_de(flash_dir, FLASH_DE_CTRL_A_USER, &offs, &size);
>  	if (err) {
>  		ASD_DPRINTK("couldn't find CTRL-A user settings section\n");
> -		ASD_DPRINTK("Creating default CTRL-A user settings section\n");
> -
> -		dflt_ps.id0 = 'h';
> -		dflt_ps.num_phys = 8;
> -		for (i =0; i < ASD_MAX_PHYS; i++) {
> -			memcpy(dflt_ps.phy_ent[i].sas_addr,
> -			       asd_ha->hw_prof.sas_addr, SAS_ADDR_SIZE);
> -			dflt_ps.phy_ent[i].sas_link_rates = 0x98;
> -			dflt_ps.phy_ent[i].flags = 0x0;
> -			dflt_ps.phy_ent[i].sata_link_rates = 0x0;
> -		}
> -
> -		size = sizeof(struct asd_ctrla_phy_settings);
> -		ps = &dflt_ps;
> +		goto out;

I did think about that.  There does seem to be a definite reason to
expect the phy setting read to succeed even though the nvram read
failed.  I think the reason was that there were some aic94xx cards that
had no nvram and therefore always failed the read, but I can't find any
evidence of that any more.

James


  reply	other threads:[~2014-11-24 16:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04  7:10 [PATCH] aic94xx: Fixup compilation warning Hannes Reinecke
2014-11-06  6:37 ` Christoph Hellwig
2014-11-24 13:40 ` Christoph Hellwig
2014-11-24 15:39   ` James Bottomley
2014-11-24 15:55     ` Hannes Reinecke
2014-11-24 16:04   ` Tomas Henzl
2014-11-24 16:10     ` James Bottomley [this message]
2014-11-24 16:34       ` Tomas Henzl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416845409.2194.7.camel@parallels.com \
    --to=jbottomley@parallels.com \
    --cc=hare@suse.de \
    --cc=hch@infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=thenzl@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox