Skip to content

Commit 3795e99

Browse files
committed
soc: aspeed: lpc-snoop: Ensure model_data is valid
of_device_get_match_data() can return NULL, though shouldn't in current circumstances. Regardless, initialise model_data closer to use so it's clear we need to test for validity prior to dereferencing. Acked-by: Jean Delvare <jdelvare@suse.de> Link: https://patch.msgid.link/20250616-aspeed-lpc-snoop-fixes-v2-3-3cdd59c934d3@codeconstruct.com.au Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
1 parent 56448e7 commit 3795e99

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/soc/aspeed/aspeed-lpc-snoop.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,9 @@ static int aspeed_lpc_enable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
186186
struct device *dev,
187187
int channel, u16 lpc_port)
188188
{
189-
int rc = 0;
189+
const struct aspeed_lpc_snoop_model_data *model_data;
190190
u32 hicr5_en, snpwadr_mask, snpwadr_shift, hicrb_en;
191-
const struct aspeed_lpc_snoop_model_data *model_data =
192-
of_device_get_match_data(dev);
191+
int rc = 0;
193192

194193
if (WARN_ON(lpc_snoop->chan[channel].enabled))
195194
return -EBUSY;
@@ -236,9 +235,10 @@ static int aspeed_lpc_enable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
236235
regmap_update_bits(lpc_snoop->regmap, HICR5, hicr5_en, hicr5_en);
237236
regmap_update_bits(lpc_snoop->regmap, SNPWADR, snpwadr_mask,
238237
lpc_port << snpwadr_shift);
239-
if (model_data->has_hicrb_ensnp)
240-
regmap_update_bits(lpc_snoop->regmap, HICRB,
241-
hicrb_en, hicrb_en);
238+
239+
model_data = of_device_get_match_data(dev);
240+
if (model_data && model_data->has_hicrb_ensnp)
241+
regmap_update_bits(lpc_snoop->regmap, HICRB, hicrb_en, hicrb_en);
242242

243243
lpc_snoop->chan[channel].enabled = true;
244244

0 commit comments

Comments
 (0)