All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/ca0132 - fix possible NULL pointer use
@ 2017-01-11 13:39 Arnd Bergmann
  2017-01-11 16:26   ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2017-01-11 13:39 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai; +Cc: Arnd Bergmann, alsa-devel, linux-kernel

gcc-7 caught what it considers a NULL pointer dereference:

sound/pci/hda/patch_ca0132.c: In function 'dspio_scp.constprop':
sound/pci/hda/patch_ca0132.c:1487:4: error: argument 1 null where non-null expected [-Werror=nonnull]

This is plausible from looking at the function, as we compare 'reply'
to NULL earlier in it. I have not tried to analyze if there are constraints
that make it impossible to hit the bug, but adding another NULL check in
the end kills the warning and makes the function more robust.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 sound/pci/hda/patch_ca0132.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index bd7c29f8ab1e..07a9deb17477 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -1482,6 +1482,9 @@ static int dspio_scp(struct hda_codec *codec,
 		} else if (ret_size != reply_data_size) {
 			codec_dbg(codec, "RetLen and HdrLen .NE.\n");
 			return -EINVAL;
+		} else if (!reply) {
+			codec_dbg(codec, "NULL reply\n");
+			return -EINVAL;
 		} else {
 			*reply_len = ret_size*sizeof(unsigned int);
 			memcpy(reply, scp_reply.data, *reply_len);
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ALSA: hda/ca0132 - fix possible NULL pointer use
  2017-01-11 13:39 [PATCH] ALSA: hda/ca0132 - fix possible NULL pointer use Arnd Bergmann
@ 2017-01-11 16:26   ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2017-01-11 16:26 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Jaroslav Kysela, alsa-devel, linux-kernel

On Wed, 11 Jan 2017 14:39:44 +0100,
Arnd Bergmann wrote:
> 
> gcc-7 caught what it considers a NULL pointer dereference:
> 
> sound/pci/hda/patch_ca0132.c: In function 'dspio_scp.constprop':
> sound/pci/hda/patch_ca0132.c:1487:4: error: argument 1 null where non-null expected [-Werror=nonnull]
> 
> This is plausible from looking at the function, as we compare 'reply'
> to NULL earlier in it. I have not tried to analyze if there are constraints
> that make it impossible to hit the bug, but adding another NULL check in
> the end kills the warning and makes the function more robust.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks.


Takashi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ALSA: hda/ca0132 - fix possible NULL pointer use
@ 2017-01-11 16:26   ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2017-01-11 16:26 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Jaroslav Kysela, alsa-devel, linux-kernel

On Wed, 11 Jan 2017 14:39:44 +0100,
Arnd Bergmann wrote:
> 
> gcc-7 caught what it considers a NULL pointer dereference:
> 
> sound/pci/hda/patch_ca0132.c: In function 'dspio_scp.constprop':
> sound/pci/hda/patch_ca0132.c:1487:4: error: argument 1 null where non-null expected [-Werror=nonnull]
> 
> This is plausible from looking at the function, as we compare 'reply'
> to NULL earlier in it. I have not tried to analyze if there are constraints
> that make it impossible to hit the bug, but adding another NULL check in
> the end kills the warning and makes the function more robust.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks.


Takashi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-11 16:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-11 13:39 [PATCH] ALSA: hda/ca0132 - fix possible NULL pointer use Arnd Bergmann
2017-01-11 16:26 ` Takashi Iwai
2017-01-11 16:26   ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.