* Re: [PATCH] Fix pointer arithmetic in hpt3xx driver code (3rd try) [not found] <20080906171850.GF26371@google.com> @ 2008-09-07 9:21 ` Sergei Shtylyov 2008-09-07 11:20 ` Sergei Shtylyov 0 siblings, 1 reply; 4+ messages in thread From: Sergei Shtylyov @ 2008-09-07 9:21 UTC (permalink / raw) To: Masoud Sharbiani; +Cc: bzolnier, akpm, linux-kernel, linux-ide Hello. Masoud Sharbiani wrote: > git commit 74811f355f4f69a187fa74892dcf2a684b84ce99 causes crash at > module load (or boot) time on my machine with a hpt374 controller. > The reason for this is that for initializing second controller which sets > (hwif->dev == host->dev[1]) to true (1), adds 1 to a void ptr, which > advances it by one byte instead of advancing it by sizeof(hpt_info) bytes. > Because of this, all initialization functions get corrupted data in info > variable which causes a crash at boot time. > > This patch fixes that and makes my machine boot again. > This description is better, thanks. You could also mention that you're factoring out the code to get to the 'struct hpt_info' into a separate function... > Signed-Off-By: Masoud Sharbiani <masouds@google.com> > > diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c > index eb107ee..4eae284 100644 > --- a/drivers/ide/pci/hpt366.c > +++ b/drivers/ide/pci/hpt366.c > @@ -613,6 +613,14 @@ static int check_in_drive_list(ide_drive_t *drive, const char **list) > return 0; > } > > +static struct hpt_info *hpt3xx_get_info(struct device *dev) > +{ > + struct ide_host *host = pci_get_drvdata(to_pci_dev(pci_dev)); > Oops, this just won't compile. :-/ And please re-consider passing 'struct pci_dev *' to this function since it's pre-calculated by the callers and is used by them otherwise in 5 (not even 4) cases out of 7. > + struct hpt_info *info = (struct hpt_info *)host->host_priv; > + > + return dev == host->dev[1] ? info + 1 : info; > The 'dev' here would turn into '&dev->dev' if the parameter type would be changed. MBR, Sergei ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix pointer arithmetic in hpt3xx driver code (3rd try) 2008-09-07 9:21 ` [PATCH] Fix pointer arithmetic in hpt3xx driver code (3rd try) Sergei Shtylyov @ 2008-09-07 11:20 ` Sergei Shtylyov 2008-09-07 18:10 ` Bartlomiej Zolnierkiewicz 0 siblings, 1 reply; 4+ messages in thread From: Sergei Shtylyov @ 2008-09-07 11:20 UTC (permalink / raw) To: Masoud Sharbiani; +Cc: bzolnier, akpm, linux-kernel, linux-ide Hello, I wrote: >> diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c >> index eb107ee..4eae284 100644 >> --- a/drivers/ide/pci/hpt366.c >> +++ b/drivers/ide/pci/hpt366.c >> @@ -613,6 +613,14 @@ static int check_in_drive_list(ide_drive_t >> *drive, const char **list) >> return 0; >> } >> >> +static struct hpt_info *hpt3xx_get_info(struct device *dev) >> +{ >> + struct ide_host *host = pci_get_drvdata(to_pci_dev(pci_dev)); >> > > Oops, this just won't compile. :-/ BTW, there's no need to invoke to_pci_dev() at all since pci_get_drvdata(dev) boils down to dev_get_drvdata(&dev->dev) call. So, in order not to waste time on useless pointer tricks, we should just invoke the latter here. > And please re-consider passing 'struct pci_dev *' to this function > since it's pre-calculated by the callers and is used by them otherwise > in 5 (not even 4) cases out of 7. > Well, since to_pci_dev() is unnecessary here, I'm taking my request back. :-) MBR, Sergei ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix pointer arithmetic in hpt3xx driver code (3rd try) 2008-09-07 11:20 ` Sergei Shtylyov @ 2008-09-07 18:10 ` Bartlomiej Zolnierkiewicz 2008-09-08 17:21 ` Masoud Sharbiani 0 siblings, 1 reply; 4+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-09-07 18:10 UTC (permalink / raw) To: Sergei Shtylyov; +Cc: Masoud Sharbiani, akpm, linux-kernel, linux-ide Hi, Masoud/Sergei: sorry for the bug and thanks for fixing it. On Sunday 07 September 2008, Sergei Shtylyov wrote: > Hello, I wrote: > >> diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c > >> index eb107ee..4eae284 100644 > >> --- a/drivers/ide/pci/hpt366.c > >> +++ b/drivers/ide/pci/hpt366.c > >> @@ -613,6 +613,14 @@ static int check_in_drive_list(ide_drive_t > >> *drive, const char **list) > >> return 0; > >> } > >> > >> +static struct hpt_info *hpt3xx_get_info(struct device *dev) > >> +{ > >> + struct ide_host *host = pci_get_drvdata(to_pci_dev(pci_dev)); > >> > > > > Oops, this just won't compile. :-/ > > BTW, there's no need to invoke to_pci_dev() at all since > pci_get_drvdata(dev) boils down to dev_get_drvdata(&dev->dev) call. So, > in order not to waste time on useless pointer tricks, we should just > invoke the latter here. I corrected this and applied the patch. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix pointer arithmetic in hpt3xx driver code (3rd try) 2008-09-07 18:10 ` Bartlomiej Zolnierkiewicz @ 2008-09-08 17:21 ` Masoud Sharbiani 0 siblings, 0 replies; 4+ messages in thread From: Masoud Sharbiani @ 2008-09-08 17:21 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: Sergei Shtylyov, akpm, linux-kernel, linux-ide On Sun, Sep 07, 2008 at 08:10:03PM +0200, Bartlomiej Zolnierkiewicz wrote: > > Hi, > > Masoud/Sergei: sorry for the bug and thanks for fixing it. > > On Sunday 07 September 2008, Sergei Shtylyov wrote: > > Hello, I wrote: > > >> diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c > > >> index eb107ee..4eae284 100644 > > >> --- a/drivers/ide/pci/hpt366.c > > >> +++ b/drivers/ide/pci/hpt366.c > > >> @@ -613,6 +613,14 @@ static int check_in_drive_list(ide_drive_t > > >> *drive, const char **list) > > >> return 0; > > >> } > > >> > > >> +static struct hpt_info *hpt3xx_get_info(struct device *dev) > > >> +{ > > >> + struct ide_host *host = pci_get_drvdata(to_pci_dev(pci_dev)); > > >> > > > > > > Oops, this just won't compile. :-/ > > > > BTW, there's no need to invoke to_pci_dev() at all since > > pci_get_drvdata(dev) boils down to dev_get_drvdata(&dev->dev) call. So, > > in order not to waste time on useless pointer tricks, we should just > > invoke the latter here. > > I corrected this and applied the patch. Thanks! Masoud ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-09-08 17:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20080906171850.GF26371@google.com>
2008-09-07 9:21 ` [PATCH] Fix pointer arithmetic in hpt3xx driver code (3rd try) Sergei Shtylyov
2008-09-07 11:20 ` Sergei Shtylyov
2008-09-07 18:10 ` Bartlomiej Zolnierkiewicz
2008-09-08 17:21 ` Masoud Sharbiani
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).