Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcma: return error in bcma_sprom_get() when fallback fails

When not SPROM is available a fallback mechanism is used. However,
when that fails the code currently continues. This patch assures
that the bcma_sprom_get() function aborts when that happens.

Cc: Rafal Milecki <zajec5@gmail.com>
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Arend van Spriel and committed by
John W. Linville
4ac887cf 5c17ddc4

+17 -10
+17 -10
drivers/bcma/sprom.c
··· 49 49 static int bcma_fill_sprom_with_fallback(struct bcma_bus *bus, 50 50 struct ssb_sprom *out) 51 51 { 52 - if (!get_fallback_sprom) 53 - return -ENOENT; 52 + int err; 54 53 55 - return get_fallback_sprom(bus, out); 54 + if (!get_fallback_sprom) { 55 + err = -ENOENT; 56 + goto fail; 57 + } 58 + 59 + err = get_fallback_sprom(bus, out); 60 + if (err) 61 + goto fail; 62 + 63 + pr_debug("Using SPROM revision %d provided by" 64 + " platform.\n", bus->sprom.revision); 65 + return 0; 66 + fail: 67 + pr_warn("Using fallback SPROM failed (err %d)\n", err); 68 + return err; 56 69 } 57 70 58 71 /************************************************** ··· 330 317 * available for this device in some other storage. 331 318 */ 332 319 err = bcma_fill_sprom_with_fallback(bus, &bus->sprom); 333 - if (err) { 334 - pr_warn("Using fallback SPROM failed (err %d)\n", err); 335 - } else { 336 - pr_debug("Using SPROM revision %d provided by" 337 - " platform.\n", bus->sprom.revision); 338 - return 0; 339 - } 320 + return err; 340 321 } 341 322 342 323 sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),