From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v6 04/26] pmic: Extend PMIC framework to support multiple instances of PMIC devices
Date: Mon, 12 Nov 2012 09:23:02 +0100 [thread overview]
Message-ID: <20121112092302.32878b42@amdc308.digital.local> (raw)
In-Reply-To: <20121110010137.43bdaab4@wker>
Hi Anatolij,
Thank you for feedback.
> Hi Lukasz,
>
> On Fri, 09 Nov 2012 08:42:09 +0100
> Lukasz Majewski <l.majewski@samsung.com> wrote:
> ...
> > diff --git a/board/davedenx/qong/qong.c b/board/davedenx/qong/qong.c
> > index c41f11d..e8c23f8 100644
> > --- a/board/davedenx/qong/qong.c
> > +++ b/board/davedenx/qong/qong.c
> > @@ -28,7 +28,7 @@
> > #include <asm/arch/sys_proto.h>
> > #include <asm/io.h>
> > #include <nand.h>
> > -#include <pmic.h>
> > +#include <power/pmic.h>
> > #include <fsl_pmic.h>
> > #include <asm/gpio.h>
> > #include "qong_fpga.h"
> > @@ -173,8 +173,8 @@ int board_late_init(void)
> > u32 val;
> > struct pmic *p;
> >
> > - pmic_init();
> > - p = get_pmic();
> > + pmic_init(I2C_PMIC);
> > + p = pmic_get("FSL_PMIC");
>
> Now the pmic struct is allocated dynamically, we should check if the
> allocation failed and bail out in this case to prevent dereferencing
> null pointer in pmic_get().
>
> ...
> > diff --git a/drivers/misc/pmic_fsl.c b/drivers/misc/pmic_fsl.c
> > index 0ff75ed..868c3c4 100644
> > --- a/drivers/misc/pmic_fsl.c
> > +++ b/drivers/misc/pmic_fsl.c
> > @@ -23,7 +23,7 @@
> >
> > #include <common.h>
> > #include <spi.h>
> > -#include <pmic.h>
> > +#include <power/pmic.h>
> > #include <fsl_pmic.h>
> >
> > #if defined(CONFIG_PMIC_SPI)
> > @@ -33,9 +33,9 @@ static u32 pmic_spi_prepare_tx(u32 reg, u32 *val,
> > u32 write) }
> > #endif
> >
> > -int pmic_init(void)
> > +int pmic_init(unsigned char bus)
> > {
> > - struct pmic *p = get_pmic();
> > + struct pmic *p = pmic_alloc();
> > static const char name[] = "FSL_PMIC";
> >
> > p->name = name;
> > @@ -54,7 +54,7 @@ int pmic_init(void)
> > p->interface = PMIC_I2C;
> > p->hw.i2c.addr = CONFIG_SYS_FSL_PMIC_I2C_ADDR;
> > p->hw.i2c.tx_num = 3;
> > - p->bus = I2C_PMIC;
> > + p->bus = bus;
>
> In the case the pmic_alloc() fails this code is now writing to pmic
> struct at NULL. Please check the return value of pmic_alloc() and
> bail out if needed. This applies to other drivers changed by this
> patch. Can you please fix it and resubmit a fixed patch 04/26.
One more time, thanks for spotting it. I will go through the patch
series and correct it.
BTW. I'm really stunned, how I managed to overlook this bug....
>
> Thanks,
> Anatolij
--
Best regards,
Lukasz Majewski
Samsung Poland R&D Center | Linux Platform Group
next prev parent reply other threads:[~2012-11-12 8:23 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-09 7:42 [U-Boot] [PATCH v6 00/26] pmic: Redesign PMIC framework to support multiple instances of devices Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 01/26] pmic:i2c: Handle PMIC I2C transmission comprising of two bytes Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 02/26] pmic:i2c: Add I2C sensor byte order (big/little) to PMIC framework Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 03/26] pmic:max8997: Switch the MAX8997 PMIC to be used with multibus I2C Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 04/26] pmic: Extend PMIC framework to support multiple instances of PMIC devices Lukasz Majewski
2012-11-10 0:01 ` Anatolij Gustschin
2012-11-12 8:23 ` Lukasz Majewski [this message]
2012-11-09 7:42 ` [U-Boot] [PATCH v6 05/26] pmic: Introduce power_init_board() method at ./lib/board.c file Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 06/26] pmic: Enable power_board_init() support at TRATS Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 07/26] pmic:chrg: Common information about charger and battery (power_chrg.h) Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 08/26] pmic: Move pmic related code to ./drivers/power directory Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 09/26] pmic: Extend struct pmic to support battery and charger related operations Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 10/26] pmic:battery: Support for Trats Battery at PMIC framework Lukasz Majewski
2012-11-10 0:11 ` Anatolij Gustschin
2012-11-09 7:42 ` [U-Boot] [PATCH v6 11/26] pmic:muic: Support for MUIC built into MAX8997 device Lukasz Majewski
2012-11-10 0:17 ` Anatolij Gustschin
2012-11-09 7:42 ` [U-Boot] [PATCH v6 12/26] pmic:fuel-gauge: Support for MAX17042 fuel-gauge Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 13/26] pmic:max8997: Function for calculating LDO internal register value Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 14/26] arm:trats:pmic: Default PMIC(MAX8997) initialization for Samsung's TRATS board Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 15/26] arm:trats:pmic: Enable MUIC (MAX8997) at " Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 16/26] arm:trats:pmic: Enable fuel-gauge (MAX17042) " Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 17/26] arm:trats:pmic: Enable battery support " Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 18/26] pmic:max8997: Support for MAX8997 internal charger control Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 19/26] arm:trats:pmic: Power consumption reduction state for Samsung's TRATS board Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 20/26] arm:trats:pmic: Support for charging battery at " Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 21/26] pmic: Extend PMIC framework to support battery related commands Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 22/26] power:pmic: Rename ./drivers/power/pmic_* to ./drivers/power/power_* files Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 23/26] power:pmic: Rename CONFIG_PMIC* defines to CONFIG_POWER Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 24/26] power:pmic: Rename CONFIG_DIALOG_PMIC defines to CONFIG_DIALOG_POWER Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 25/26] arm:goni:pmic: Adjust GONI target platform board to new PMIC framework Lukasz Majewski
2012-11-09 7:42 ` [U-Boot] [PATCH v6 26/26] arm:universal_c210:pmic: Adjust C210 Universal " Lukasz Majewski
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=20121112092302.32878b42@amdc308.digital.local \
--to=l.majewski@samsung.com \
--cc=u-boot@lists.denx.de \
/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