Re: [PATCH] Fix pointer arithmetic in hpt3xx driver code

From: Sergei Shtylyov
Date: Fri Sep 05 2008 - 14:03:53 EST


Masoud Sharbiani wrote:

Hi there,
git commit 74811f355f4f69a187fa74892dcf2a684b84ce99 causes crash at
module load (or boot) time on my machine with a hpt374 controller.
Sergei says this is due to the pointer arithmatic. This patch fixes that
and makes my machine boot again.

Signed-Off-By: Masoud Sharbiani <masouds@xxxxxxxxxx>

diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index eb107ee..f41f3fd 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(void *host_priv, struct device *hwif_dev, struct device *host_dev)

Ugh, that's oversimplified and doesn't save much...
I rather meant the following prototype:

static struct hpt_info *hpt3xx_get_info(struct pci_dev *dev)

In case it'll be too complex for you, I'll do it myself later.

+{
+ struct hpt_info *info = (struct hpt_info *)host_priv;

Newline needed after the declaration block.

+ if (hwif_dev == host_dev)
return info + 1;
else
return info;

or

return hwif_dev == host_dev ? info + 1 : info;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/